Commit 2f538ac4 authored by luzhzh's avatar luzhzh
Browse files

need define int first

parent 85085171
......@@ -40,8 +40,9 @@
class Solution {
public int missingNumber(int[] nums) {
int res = 0;
int i = 0;
//注意数组越界情况
for (int i = 0; i < nums.length;i++){
for (; i < nums.length;i++){
// i 表示完整数组中的数字,与原数组中的数字 nums[i] 进行异或,再与保存的结果异或
res = res^i^nums[i];
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment