← Greedy

Pattern Recognition Drill

#147 — Jump Game II

Medium Greedy

The Problem

Given array where each element is max jump length, find minimum jumps to reach the last index.

What approach would you use?

Think about it before scrolling down.

Key Signals

Greedy

Track current jump boundary and farthest reach. When hitting boundary, jump++, extend boundary. O(n).

Alt: Dynamic Programming

dp[i] = min jumps to reach i. O(n²) — much slower.

Common Trap

Don't BFS with a queue — the greedy two-pointer approach is O(n) with O(1) space.

← #146