Javascript Functional Programming approach


  • 1
    E

    Time complexity: O(m+n)

    var intersection = function(nums1, nums2) {
        var set = new Set(nums1);
        return nums2.filter(n => set.delete(n));
    };
    

Log in to reply
 

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