You are given two arrays `arr1` and `arr2`, where `arr2` always contains integers.

Write the function `find_array(arr1, arr2)` such that:

For `arr1 = ['a', 'a', 'a', 'a', 'a']`, `arr2 = [2, 4]`
`find_array returns ['a', 'a']`

For `arr1 = [0, 1, 5, 2, 1, 8, 9, 1, 5]`, `arr2 = [1, 4, 7]`
`find_array returns [1, 1, 1]`

For `arr1 = [0, 3, 4]`, `arr2 = [2, 6]`
`find_array returns [4]`

For `arr1=["a","b","c","d"]` , `arr2=[2,2,2]`,
`find_array returns ["c","c","c"]`

For `arr1=["a","b","c","d"]`, `arr2=[3,0,2]`
`find_array returns ["d","a","c"]`

If either `arr1` or `arr2` is empty, you should return an empty arr (empty list in python,
empty vector in c++). Note for c++ use std::vector arr1, arr2.

Source: codewars | Difficulty: EASY
Tags: Ad-hoc

Starter code: def find_array(arr1, arr2):
	

Solutions:
def find_array(arr1, arr2):
	return [arr1[i] for i in arr2 if i < len(arr1)]


def find_array(arr1, arr2):
	arr = []
	try:
		for i in arr2:
			if len(arr1) == 0 or len(arr2) == 0:
				return []
			else:
				arr.append(arr1[i])
	except IndexError:
		return arr
	return arr


def find_array(arr1, arr2):
	list1 = []
	for num in arr2:
		if num < len(arr1):
			list1.append(arr1[num])
	return list1


def find_array(arr1, arr2):
	return [arr1[x] for x in arr2 if x <= len(arr1)]


def find_array(xs, ys):
	return [xs[y] for y in ys if 0 <= y < len(xs)]


def find_array(arr1, arr2):
	return list() if not arr1 or not arr2 else [arr1[i] for i in arr2 if i <= len(arr1)]


def find_array(arr1, arr2):
	return [] if len(arr1) * len(arr2) == 0 else [arr1[i] for i in arr2 if i < len(arr1)]


def find_array(arr1, arr2):
	arr2 = set(arr2)
	return [n for (i, n) in enumerate(arr1) if i in arr2]