LeetCode:两个数组的交集 II
2018-07-07 21:35
375 查看
C++示例程序:
class Solution { public: vector<int> intersect(vector<int>& nums1, vector<int>& nums2) { vector<int> result; unordered_map<int, int> um; for (int i = 0; i < nums1.size(); i++) { um[nums1[i]] ++; } for (int i = 0; i < nums2.size(); i++) { if (um[nums2[i]]) { result.push_back(nums2[i]); um[nums2[i]] --; } } return result; } };
相关文章推荐
- [easy]【leetcode】【java】 Intersection of Two Arrays II 两个数组的交集
- LeetCode--350. Intersection of Two Arrays II(两个数组的交集)Python
- Leetcode:350. Intersection of Two Arrays II 求两个数组的交集
- leetcode-350 Intersection of Two Arrays II 求两个数组的交集 面试见到了吗?
- Leetcode 350. Intersection of Two Arrays II 两个数组的交集 II
- [LeetCode] Intersection of Two Arrays II 两个数组的交集II
- [LeetCode]350. Intersection of Two Arrays II(求两个数组交集 II)
- Leetcode 两个数组的交集 II
- leetcode 350. Intersection of Two Arrays II 两个数组的交集
- leetcode_350(求两个数组的交集)
- 350. Intersection of Two Arrays II (求两个数组的交集,包含重复元素)
- leetcode 349:两个数组的交集I
- 【初级算法】6. 两个数组的交集 II
- LeetCode 350. Intersection of Two Arrays II (两个数组的相交之二)
- Leetcode :Intersection of Two Arrays 两个数组的交集
- [LeetCode] 350. Intersection of Two Arrays II 两个数组相交II
- Intersection of Two Arrays II两个数组交集(重要!)
- [LeetCode] Intersection of Two Arrays II 两个数组相交之二
- LeetCode 350. Intersection of Two Arrays II(数组交集)