File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 2929264|[ Ugly Number II] ( ./0264-ugly-number-ii.js ) |Medium|
3030283|[ Move Zeroes] ( ./0283-move-zeroes.js ) |Easy|
3131345|[ Reverse Vowels of a String] ( ./0345-reverse-vowels-of-a-string.js ) |Easy|
32+ 349|[ Intersection of Two Arrays] ( ./0349-intersection-of-two-arrays.js ) |Easy|
3233350|[ Intersection of Two Arrays II] ( ./0350-intersection-of-two-arrays-ii.js ) |Easy|
3334387|[ First Unique Character in a String] ( ./0387-first-unique-character-in-a-string.js ) |Easy|
3435451|[ Sort Characters By Frequency] ( ./0451-sort-characters-by-frequency.js ) |Medium|
Original file line number Diff line number Diff line change 1+ /**
2+ * 349. Intersection of Two Arrays
3+ * https://leetcode.com/problems/intersection-of-two-arrays/
4+ * Difficulty: Easy
5+ *
6+ * Given two integer arrays `nums1` and `nums2`, return an array of their intersection.
7+ *
8+ * Each element in the result must be unique and you may return the result in any order.
9+ */
10+
11+ /**
12+ * @param {number[] } nums1
13+ * @param {number[] } nums2
14+ * @return {number[] }
15+ */
16+ var intersection = function ( nums1 , nums2 ) {
17+ const set = new Set ( nums1 ) ;
18+ return nums2 . filter ( value => set . delete ( value ) ) ;
19+ } ;
You can’t perform that action at this time.
0 commit comments