JavaScript solution, map function


  • 0
    O

    var intersection = function(nums1, nums2) {
    var res = [];
    nums2.map(function(num){
    if(nums1.indexOf(num) > -1 && res.indexOf(num) == -1){
    res.push(num);
    }
    });
    return res;
    };


Log in to reply
 

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