LeetCode 268. Missing Number
2022.07.18
問題
typescript
typescriptfunction 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 };
typescriptfunction 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 };