Skip to content

Instantly share code, notes, and snippets.

@davilima6
Created April 30, 2019 08:41
Show Gist options
  • Save davilima6/ea149a6a6269bb19eb91933b8750704e to your computer and use it in GitHub Desktop.
Save davilima6/ea149a6a6269bb19eb91933b8750704e to your computer and use it in GitHub Desktop.
Intersection Exercise
# PROBLEM
arr1 = [1, 2, 3]
arr2 = [1, 3, 4]
output = [1, 3]
# SOLUTION
def func(arr1, arr2):
set1 = set(arr1)
set2 = set(arr2)
return list(set1.intersection(set2))
# TEST
assert func(arr1, arr2) == output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment