Skip to content

Instantly share code, notes, and snippets.

@basekays
Created June 21, 2018 03:54
Show Gist options
  • Select an option

  • Save basekays/65aaa283a68ee6a9aa945c0ae7066e44 to your computer and use it in GitHub Desktop.

Select an option

Save basekays/65aaa283a68ee6a9aa945c0ae7066e44 to your computer and use it in GitHub Desktop.
var missingNumber = function(nums) {
let sum = 0;
let expectedSum = nums.length;
for (var i = 0; i < nums.length; i++) {
sum += nums[i];
expectedSum += i;
}
return expectedSum - sum;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment