Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
- sort(nums2.begin(),nums2.end());
- vector<int>result;
- for(auto u:nums1)
- {
- if(binary_search(nums2.begin(),nums2.end(),u))
- {
- result.push_back(u);
- }
- }
- sort(result.begin(),result.end());
- result.erase(unique(result.begin(),result.end()),result.end());
- return result;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement