You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
220 B
TypeScript

export function missingNumber(nums: number[]) {
let overallSum = 0;
for (let i = 0; i <= nums.length; i++) {
overallSum += i;
}
for (const num of nums) {
overallSum -= num;
}
return overallSum;
};