File tree 2 files changed +21
-0
lines changed
algorithms/queShiDeShuZiLcof
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 450
450
| # | Title | Solution | Difficulty |
451
451
| ---| ----- | -------- | ---------- |
452
452
| 面试题 08.06| [ 汉诺塔问题] ( https://leetcode-cn.com/problems/hanota-lcci/ ) | [ js] ( ./algorithms/hanotaLcc/hanotaLcc.js ) | Easy|
453
+
454
+ ## 剑指 Offer
455
+ | # | Title | Solution | Difficulty |
456
+ | ---| ----- | -------- | ---------- |
457
+ | 53 - II| [ 0~n-1中缺失的数字] ( https://leetcode-cn.com/problems/que-shi-de-shu-zi-lcof/ ) | [ js] ( ./algorithms/queShiDeShuZiLcof/solution.js ) | Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number[] } nums
3
+ * @return {number }
4
+ */
5
+ var missingNumber = function ( nums ) {
6
+ let result = 0 ;
7
+ // XOR of all values in the given array
8
+ for ( let i = 0 ; i < nums . length ; i ++ ) {
9
+ result ^= nums [ i ]
10
+ }
11
+ // XOR of all the values from 0 to length of array
12
+ for ( let i = 0 ; i <= nums . length ; i ++ ) {
13
+ result ^= i ;
14
+ }
15
+ return result ;
16
+ } ;
You can’t perform that action at this time.
0 commit comments