Think of it as BFS. Level 0 is index 0. Level 1 is all indices reachable in 1 jump. And so on. Track:
- currentEnd: the furthest index reachable with current number of jumps: furthest: the furthest index reachable with one more jump: jumps: number of jumps made When you reach currentEnd, you must jump. Update currentEnd = furthest and increment jumps. Time: O(n). Space: O(1). Without this level-based view, you would try all jump sequences in exponential time.