leetcode 349. Intersection of Two Arrays
来源:互联网 发布:微信cms系统 编辑:程序博客网 时间:2024/06/05 08:39
class Solution {public: vector<int> intersection(vector<int>& nums1, vector<int>& nums2) { sort(nums1.begin(),nums1.end()); sort(nums2.begin(),nums2.end()); int a = 0,b = 0; vector<int> ans; while(a < nums1.size() && b < nums2.size()){ if(nums1[a] == nums2[b]){ if(ans.size() ==0 || ans.back() != nums1[a]) ans.push_back(nums1[a]); a++,b++; } else if(nums1[a] > nums2[b]) b++; else a++; } return ans; }};
0 0
- leetcode 记录 349. Intersection of Two Arrays
- 349.[Leetcode]Intersection of Two Arrays
- [leetcode] 349. Intersection of Two Arrays
- Leetcode Everyday: 349. Intersection of Two Arrays
- leetcode.349. Intersection of Two Arrays
- LeetCode 349. Intersection of Two Arrays
- Leetcode 349. Intersection of Two Arrays
- leetcode 349. Intersection of Two Arrays
- leetcode 349. Intersection of Two Arrays
- LeetCode 349. Intersection of Two Arrays
- 【leetcode】 349. Intersection of Two Arrays
- Leetcode 349. Intersection of Two Arrays
- LeetCode 349. Intersection of Two Arrays
- Leetcode题解 349. Intersection of Two Arrays
- LeetCode - 349. Intersection of Two Arrays
- [Leetcode]349. Intersection of Two Arrays
- 349. Intersection of Two Arrays--LeetCode Record
- LeetCode 349. Intersection of Two Arrays
- AT&T Device Conformance Requirements - Knowledge Points
- HDU Problem 2546 饭卡【01背包】
- GDOI 8.11~8.14训练总结
- 谈谈:javascript:return 理解
- CodeForces 629BFar Relative’s Problem
- leetcode 349. Intersection of Two Arrays
- js判断PC端和移动端
- LeetCode—385. Mini Parser
- https://github.com/fusijie/Cocos-Resource
- 基于内容的推荐系统(content-based recommender system)
- 求和问题总结(leetcode 2Sum, 3Sum, 4Sum, K Sum)
- LRUCache学习渐进
- DataBinding绑定Listview
- Thrift框架实现Socket通信