The idea is to add all the numbers from 1 to n-1 and subtract from it all the numbers in the array. The result should be the missing number.

```
public int missingNumber(int[] nums) {
int s = 0;
for (int i=1; i<=nums.length; i++)
s += i - nums[i-1];
return ;
}
```