(nums, index = 0)
| 27 | }; |
| 28 | |
| 29 | const search = (nums, index = 0) => { |
| 30 | while (index < nums.length) { |
| 31 | const num = nums[index]; |
| 32 | const indexKey = index + 1; |
| 33 | |
| 34 | if (!isEqual(num, indexKey)) return indexKey; |
| 35 | |
| 36 | index += 1; |
| 37 | } |
| 38 | |
| 39 | return nums.length + 1; |
| 40 | }; |
| 41 | |
| 42 | const canSwap = (nums, num, indexNum) => |
| 43 | isPositive(num) && isInBound(num, nums) && !isEqual(num, indexNum); |
no test coverage detected