Set_intersection


  • 1
    Z
    class Solution {
    public:
        vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
            vector<int> res; 
            set<int> s1(nums1.begin(), nums1.end()); 
            set<int> s2(nums2.begin(), nums2.end()); 
            set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(), back_inserter(res));
            return res;
        }
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.