Skip to content

Commit 45ef81b

Browse files
add 268
1 parent d44ea94 commit 45ef81b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ Your ideas/fixes/algorithms are more than welcome!
217217
|272|[Closest Binary Search Tree Value II](https://leetcode.com/problems/closest-binary-search-tree-value-ii/)|[Solution](../master/src/main/java/com/stevesun/solutions/ClosestBinarySearchTreeValueII.java)| O(h+k)|O(h) | Hard| Stack
218218
|271|[Encode and Decode Strings](https://leetcode.com/problems/encode-and-decode-strings/)|[Solution](../master/src/main/java/com/stevesun/solutions/EncodeandDecodeStrings.java)| O(n)|O(1) | Medium|
219219
|270|[Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value/)|[Solution](../master/src/main/java/com/stevesun/solutions/ClosestBinarySearchTreeValue.java)| O(h)|O(1) | Easy| DFS
220-
|268|[Missing Number](https://leetcode.com/problems/missing-number/)|[Solution](../master/src/main/java/com/stevesun/solutions/PalindromePermutation.java)| O(n)|O(1) | Easy| HashMap
220+
|268|[Missing Number](https://leetcode.com/problems/missing-number/)|[Solution](../master/src/main/java/com/stevesun/solutions/_268.java)| O(n)|O(1) | Easy| Bit Manipulation
221221
|267|[Palindrome Permutation II](https://leetcode.com/problems/palindrome-permutation-ii/)|[Solution](../master/src/main/java/com/stevesun/solutions/PalindromePermutationII.java)| O(n*n!)|O(n) | Medium|
222222
|266|[Palindrome Permutation](https://leetcode.com/problems/palindrome-permutation/)|[Solution](../master/src/main/java/com/stevesun/solutions/PalindromePermutation.java)| O(n)|O(1) | Easy|
223223
|265|[Paint House II](https://leetcode.com/problems/paint-house-ii/)|[Solution](../master/src/main/java/com/stevesun/solutions/PaintHouseII.java)| ?|? | Hard|

src/main/java/com/stevesun/solutions/MissingNumber.java renamed to src/main/java/com/stevesun/solutions/_268.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
Note:
99
Your algorithm should run in linear runtime complexity. Could you implement it using only constant extra space complexity?*/
1010

11-
public class MissingNumber {
11+
public class _268 {
1212

13+
/**we could take advantage of the array indices
14+
then a number xor with itself is zero, so after we xor the entire array with all of its indices, the missing number will show up.*/
1315
public int missingNumber(int[] nums) {
1416
int xor = 0, i = 0;
1517
for(; i < nums.length; i++){

0 commit comments

Comments
 (0)