public class Solution {
public static int missingNumber(int[] nums) {
int n = nums.length + 1;
int expected = n * (n  1)/2;
int actual = 0;
int i = 0;
while(i < nums.length){
actual+=nums[i++];
}
return expected  actual;
}
}
Based on Arithmetic sum of first n consecutive numbers formula. Easy 1ms O(n) Java solution.

@sjhawar said in Based on Arithmetic sum of first n consecutive numbers formula. Easy 1ms O(n) Java solution.:
i guess it will overflow whenn > 2 ^ 16