Intersection of Two Arrays
Input:
nums1 =
[1,2,2,1]
, nums2 =
[2,2]
Output:
[2]Input:
nums1 =
[4,9,5]
, nums2 =
[9,4,9,8,4]
Output:
[9,4]Analysis & Solution
Use two hash sets
Sort both arrays, use two pointers
Binary search
Reference
Last updated