547.Intersection of Two Arrays
1.Description(Easy)
Given two arrays, write a function to compute their intersection.
Notice
Each element in the result must be unique.
The result can be in any order.
Example
Givennums1=[1, 2, 2, 1]
,nums2=[2, 2]
, return[2]
.
2.Code
Version 1: HashSet
Version 2: Sort + Binary Search
Version 3: Sort+ Merge
http://www.jiuzhang.com/solutions/intersection-of-two-arrays/
Last updated