File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 364
364
2114|[ Maximum Number of Words Found in Sentences] ( ./2114-maximum-number-of-words-found-in-sentences.js ) |Easy|
365
365
2129|[ Capitalize the Title] ( ./2129-capitalize-the-title.js ) |Easy|
366
366
2154|[ Keep Multiplying Found Values by Two] ( ./2154-keep-multiplying-found-values-by-two.js ) |Easy|
367
+ 2215|[ Find the Difference of Two Arrays] ( ./2215-find-the-difference-of-two-arrays.js ) |Easy|
367
368
2235|[ Add Two Integers] ( ./2235-add-two-integers.js ) |Easy|
368
369
2244|[ Minimum Rounds to Complete All Tasks] ( ./2244-minimum-rounds-to-complete-all-tasks.js ) |Medium|
369
370
2396|[ Strictly Palindromic Number] ( ./2396-strictly-palindromic-number.js ) |Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 2215. Find the Difference of Two Arrays
3
+ * https://leetcode.com/problems/find-the-difference-of-two-arrays/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given two 0-indexed integer arrays nums1 and nums2, return a list answer of size 2 where:
7
+ * - answer[0] is a list of all distinct integers in nums1 which are not present in nums2.
8
+ * - answer[1] is a list of all distinct integers in nums2 which are not present in nums1.
9
+ *
10
+ * Note that the integers in the lists may be returned in any order.
11
+ */
12
+
13
+ /**
14
+ * @param {number[] } nums1
15
+ * @param {number[] } nums2
16
+ * @return {number[][] }
17
+ */
18
+ var findDifference = function ( nums1 , nums2 ) {
19
+ const set1 = new Set ( nums1 ) ;
20
+ const set2 = new Set ( nums2 ) ;
21
+ return [
22
+ [ ...set1 ] . filter ( n => ! set2 . has ( n ) ) ,
23
+ [ ...set2 ] . filter ( n => ! set1 . has ( n ) )
24
+ ] ;
25
+ } ;
You can’t perform that action at this time.
0 commit comments