Maybe it takes too much memory for the largest test case where nums.length = Integer.MAX_VALUE, so we could just use int sum, target to pass OJ.

```
public class Solution {
public int missingNumber(int[] nums) {
long sum = 0, target = (long)nums.length*(long)(nums.length+1)/2;
for(int i=0;i<nums.length;i++) sum += (long)nums[i];
return (int)(target-sum);
}
}
```