Why my code is runtime error?

  • 0
    enter code here
    vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
            if(nums1.empty() || nums2.empty())
                return nums1.empty()?nums1:nums2;
            sort(nums1.begin(), nums1.end());
            sort(nums2.begin(), nums2.end());
            auto it_1 = unique(nums1.begin(), nums1.end());
            nums1.erase(it_1, nums1.end());
            auto it_2 = unique(nums2.begin(), nums2.end());
            nums1.erase(it_2, nums2.end());
            vector<int> result;
            set_intersection(nums1.begin(), nums1.end(), nums2.begin(), nums2.end(), inserter(result, result.begin()));
            return result;

Log in to reply

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