class Solution { public int missingNumber(int[] nums) { int sum = (1 + nums.length) * nums.length / 2; for(int i = 0;i < nums.length;i++) sum -= nums[i]; return sum; } } Last Modified: May 12, 2021 Archives Tip