File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 205
205
237|[ Delete Node in a Linked List] ( ./0237-delete-node-in-a-linked-list.js ) |Easy|
206
206
238|[ Product of Array Except Self] ( ./0238-product-of-array-except-self.js ) |Medium|
207
207
242|[ Valid Anagram] ( ./0242-valid-anagram.js ) |Easy|
208
+ 260|[ Single Number III] ( ./0260-single-number-iii.js ) |Medium|
208
209
263|[ Ugly Number] ( ./0263-ugly-number.js ) |Easy|
209
210
264|[ Ugly Number II] ( ./0264-ugly-number-ii.js ) |Medium|
210
211
268|[ Missing Number] ( ./0268-missing-number.js ) |Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 260. Single Number III
3
+ * https://leetcode.com/problems/single-number-iii/
4
+ * Difficulty: Medium
5
+ *
6
+ * Given an integer array nums, in which exactly two elements appear only once and all
7
+ * the other elements appear exactly twice. Find the two elements that appear only once.
8
+ * You can return the answer in any order.
9
+ */
10
+
11
+ /**
12
+ * @param {number[] } nums
13
+ * @return {number[] }
14
+ */
15
+ var singleNumber = function ( nums ) {
16
+ const set = new Set ( ) ;
17
+ nums . forEach ( n => set . has ( n ) ? set . delete ( n ) : set . add ( n ) ) ;
18
+ return Array . from ( set ) ;
19
+ } ;
You can’t perform that action at this time.
0 commit comments