@@ -0,0 +1,1110 @@
+package leetcode;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0A/**%0A * https://leetcode.com/problems/intersection-of-two-arrays-ii/%0A */%0Apublic class Problem350 %7B%0A    public int%5B%5D intersect(int%5B%5D nums1, int%5B%5D nums2) %7B%0A        Map%3CInteger, Integer%3E map = new HashMap%3C%3E();%0A        for (int num : nums1) %7B%0A            if (map.containsKey(num)) %7B%0A                map.put(num, map.get(num) + 1);%0A            %7D else %7B%0A                map.put(num, 1);%0A            %7D%0A        %7D%0A        List%3CInteger%3E list = new ArrayList%3C%3E();%0A        for (int num : nums2) %7B%0A            if (map.containsKey(num)) %7B%0A                list.add(num);%0A                int count = map.get(num);%0A                int newCount = count - 1;%0A                if (newCount == 0) %7B%0A                    map.remove(num);%0A                %7D else %7B%0A                    map.put(num, newCount);%0A                %7D%0A            %7D%0A        %7D%0A        int%5B%5D result = new int%5Blist.size()%5D;%0A        int i = 0;%0A        for (int num : list) %7B%0A            result%5Bi++%5D = num;%0A        %7D%0A        return result;%0A    %7D%0A%7D%0A

Solve problem 350