• 44.0%

https://leetcode.com/problems/intersection-of-two-arrays-ii/

Given two arrays, write a function to compute their intersection.

Note:

• Each element in the result should appear as many times as it shows in both arrays.
• The result can be in any order.

Follow up:

• What if the given array is already sorted? How would you optimize your algorithm?
• What if nums1’s size is small compared to nums2’s size? Which algorithm is better?
• What if elements of nums2 are stored on disk, and the memory is limited such that you cannot load all elements into the memory at once?

#### java

Solution 1:

https://leetcode.com/discuss/103835/ac-solution-using-java-hashmap

7ms, 63.08%, June.5th, 2016

#### cpp

Solution Mine:

12ms, 40.16%, June.5th, 2016

Solution 2:

https://leetcode.com/discuss/103787/table-solution-pointers-solution-with-time-space-complexity

12ms, 40.16%, June.5th, 2016

#### python

Solution 1:

https://leetcode.com/discuss/104046/python-o-n-simple-solution

60ms, 61.07%, June.5th, 2016

Solution 2:

https://leetcode.com/discuss/103895/straightforward-python-solution-based-on-sort

62ms, 88.22%, June.5th, 2016