(nums)
| 5 | * Space O(1) |
| 6 | */ |
| 7 | var jump = function (nums) { |
| 8 | if (nums.length <= 1) return 0; |
| 9 | let jumps = 0; |
| 10 | let maxReach = 0; |
| 11 | let steps = 0; |
| 12 | for (let i = 0; i < nums.length - 1; i++) { |
| 13 | maxReach = Math.max(maxReach, i + nums[i]); |
| 14 | if (i == steps) { |
| 15 | jumps++; |
| 16 | steps = maxReach; |
| 17 | } |
| 18 | } |
| 19 | return jumps; |
| 20 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected