Javascript Solution


  • 0
    M
    /**
     * @param {number[]} nums1
     * @param {number[]} nums2
     * @return {number[]}
     */
    var intersection = function(nums1, nums2) {
     return nums1.filter(num => { 
      return (nums2.indexOf(num) !== -1);
     }).filter((value, index, array) => { 
      return (array.indexOf(value) === index); 
     });
    };
    

Log in to reply
 

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