Skip to content

Commit 435bd73

Browse files
authored
Merge pull request MisterBooo#26 from luzhzhsoft/master
fixed 201 problem -1 can not shift bug
2 parents dc285aa + 2f538ac commit 435bd73

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

notes/LeetCode第201号问题:数字范围按位与.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
class Solution {
4949
public:
5050
int rangeBitwiseAnd(int m, int n) {
51-
int d = INT_MAX;
51+
unsigned int d = INT_MAX;
5252
while ((m & d) != (n & d)) {
5353
d <<= 1;
5454
}

notes/LeetCode第268号问题:缺失数字.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040
class Solution {
4141
public int missingNumber(int[] nums) {
4242
int res = 0;
43+
int i = 0;
4344
//注意数组越界情况
44-
for (int i = 0; i < nums.length;i++){
45+
for (; i < nums.length;i++){
4546
// i 表示完整数组中的数字,与原数组中的数字 nums[i] 进行异或,再与保存的结果异或
4647
res = res^i^nums[i];
4748
}

0 commit comments

Comments
 (0)