Skip to content

Instantly share code, notes, and snippets.

@vicxruiz
Created May 6, 2020 14:58
Show Gist options
  • Save vicxruiz/26179ec39c282f90a448f80dd2918632 to your computer and use it in GitHub Desktop.
Save vicxruiz/26179ec39c282f90a448f80dd2918632 to your computer and use it in GitHub Desktop.
Given two arrays, write a function to compute their intersection.
Example 1:
Input: nums1 = [1,2,2,1], nums2 = [2,2]
Output: [2]
Example 2:
Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]
Output: [9,4]
Note:
Each element in the result must be unique.
The result can be in any order.
func intersection(_ nums1: [Int], _ nums2: [Int]) -> [Int] {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment