LeetCode 268. Missing Number
2022.07.18
問題
https://leetcode.com/problems/missing-number/
typescript
function missingNumber(nums: number[]): number {
nums.sort((a, b) => a - b)
let cnt = 0
for (const n of nums) {
if (cnt !== n) return cnt
cnt++
}
return nums.length
};