(nums, index = 0)
| 12 | }; |
| 13 | |
| 14 | const cyclicSort = (nums, index = 0) => { |
| 15 | while (index < nums.length) { |
| 16 | const num = nums[index]; |
| 17 | const indexKey = num - 1; |
| 18 | const indexNum = nums[indexKey]; |
| 19 | |
| 20 | if (canSwap(nums, num, indexNum)) { |
| 21 | swap(nums, index, indexKey); |
| 22 | continue; |
| 23 | } |
| 24 | |
| 25 | index += 1; |
| 26 | } |
| 27 | }; |
| 28 | |
| 29 | const search = (nums, index = 0) => { |
| 30 | while (index < nums.length) { |
no test coverage detected