leetcode---Intersection of Two Arrays
来源:互联网 发布:2007年网络歌曲 编辑:程序博客网 时间:2024/05/29 04:22
Total Accepted: 77145
Total Submissions: 166815
Difficulty: Easy
Contributors: Admin
Given two arrays, write a function to compute their intersection.
Example:
Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].
Note:
Each element in the result must be unique.
The result can be in any order.
class Solution {public: vector<int> intersection(vector<int>& nums1, vector<int>& nums2) { set<int> s1; set<int> s2; for(int i=0; i<nums1.size(); i++) s1.insert(nums1[i]); for(int i=0; i<nums2.size(); i++) s2.insert(nums2[i]); vector<int> s; set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(), back_inserter(s)); return s; }};
0 0
- [LeetCode] Intersection of Two Arrays
- LeetCode Intersection of Two Arrays
- LeetCode:Intersection of Two Arrays
- 【leetcode】Intersection of Two Arrays
- leetcode Intersection of Two Arrays
- 【leetcode】Intersection of Two Arrays
- leetcode:Intersection of Two Arrays
- [Leetcode]Intersection of Two Arrays
- LeetCode:Intersection of Two Arrays
- LeetCode: Intersection of Two Arrays
- leetcode ----Intersection of Two Arrays
- LeetCode Intersection of Two Arrays
- [Leetcode] Intersection of Two Arrays
- LEETCODE--Intersection of Two Arrays
- LeetCode : Intersection of Two Arrays
- leetcode---Intersection of Two Arrays
- leetCode---Intersection of Two Arrays
- leetcode[Intersection of Two Arrays]
- HTTP简介
- Android——数据库sqlite存储数据
- 系统时间格式设置
- 主题:免费的论文查重网站
- IOC/DIP其实是一种管理思想
- leetcode---Intersection of Two Arrays
- c++加窗
- my-s.cnf
- java7 concurrentHashMap
- C++第二次实验-循环程序设计-项目7(输出完数)
- 通过maven profile实现多套环境配置
- jQuery选择器的结果是prevobject:e.fn.e.init [1]我怎么得到一个元素
- WebView 图片大小自适应问题
- leetcode 100. Same Tree