← Pointer Manipulation

Micro-Drill #147 — Jump game II (greedy BFS)

Pointer Manipulation Target: 10s

Track farthest reachable and current boundary. Increment jumps when boundary is hit.

jumps = cur_end = farthest = 0
for i in range(len(nums) - 1):
    farthest = max(farthest, i + nums[i])
    if i == cur_end:
        jumps += 1
        cur_end = farthest

Type it from memory. Go.

Practice Problems

Related Coding Drills

← Micro #146 Micro #148 →