| 1 | fun jumpToTheEnd(nums: List<Int>): Boolean { |
| 2 | // Set the initial destination to the last index in the array. |
| 3 | var destination = nums.size - 1 |
| 4 | // Traverse the array in reverse to see if the destination can be |
| 5 | // reached by earlier indexes. |
| 6 | for (i in nums.size - 2 downTo 0) { |
| 7 | // If we can reach the destination from the current index, |
| 8 | // set this index as the new destination. |
| 9 | if (i + nums[i] >= destination) { |
| 10 | destination = i |
| 11 | } |
| 12 | } |
| 13 | // If the destination is index 0, we can jump to the end from index |
| 14 | // 0. |
| 15 | return destination == 0 |
| 16 | } |
nothing calls this directly
no outgoing calls
no test coverage detected