public int missingNumber(int[] nums) {
int total = 0;
for(int i = 1; i<=nums.length; i++){
total = total+inums[i1];
}
return total;
}
Easy 1ms JAVA solution

Yeah, this is going to overflow if nums.length is greater than about 2*sqrt(Integer.MAX_VALUE). As a quick workaround, just make total be a long. Here is my similar solution:
public class Solution { public int missingNumber(int[] nums) { if (null == nums) { return 0; } long all = 0; long present = 0; for (int i=0; i<nums.length; ++i) { all += i; present += nums[i]; } return (int)(allpresent + nums.length); } }