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 39
39
118|[ Pascal's Triangle] ( ./0118-pascals-triangle.js ) |Easy|
40
40
119|[ Pascal's Triangle II] ( ./0119-pascals-triangle-ii.js ) |Easy|
41
41
121|[ Best Time to Buy and Sell Stock] ( ./0121-best-time-to-buy-and-sell-stock.js ) |Easy|
42
+ 136|[ Single Number] ( ./0136-single-number.js ) |Easy|
42
43
151|[ Reverse Words in a String] ( ./0151-reverse-words-in-a-string.js ) |Medium|
43
44
152|[ Maximum Product Subarray] ( ./0152-maximum-product-subarray.js ) |Medium|
44
45
217|[ Contains Duplicate] ( ./0217-contains-duplicate.js ) |Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 136. Single Number
3
+ * https://leetcode.com/problems/single-number/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given a non-empty array of integers nums, every element appears twice
7
+ * except for one. Find that single one.
8
+ *
9
+ * You must implement a solution with a linear runtime complexity and
10
+ * use only constant extra space.
11
+ */
12
+
13
+ /**
14
+ * @param {number[] } nums
15
+ * @return {number }
16
+ */
17
+ var singleNumber = function ( nums ) {
18
+ return nums . reduce ( ( result , num ) => result ^= num , 0 ) ;
19
+ } ;
You can’t perform that action at this time.
0 commit comments