(nums)
| 172 | const isSame = (a, b) => a === b; |
| 173 | |
| 174 | const search = (nums) => { |
| 175 | for (let index = 0; index < nums.length; index++) { |
| 176 | /* Time O(N) */ |
| 177 | const [num, arrayIndex] = [nums[index], index + 1]; |
| 178 | |
| 179 | if (!isSame(num, arrayIndex)) return num; |
| 180 | } |
| 181 | |
| 182 | return nums.length; |
| 183 | }; |
| 184 | |
| 185 | /** |
| 186 | * https://leetcode.com/problems/find-the-duplicate-number/ |
no test coverage detected