```
public int missingNumber(int[] nums) {
int length = nums.length;
int sum = 0;
int acc = 0;
for(int k=0;k<length;k++){
sum += nums[k];
acc += k+1;
}
if(sum ==acc)return 0;
else
return acc - sum;
}
```