LC 45
LeetCode 45 · Medium

Jump Game II

Return the minimum number of jumps to reach the last index.

Greedy → · High frequency · Solve on LeetCode →

Try it

Step through the core mechanic. The simulator below runs the greedy shape this problem is built on.

Walk the pattern

No dedicated step-through for this one yet. The shape is Greedy — its pattern page has the interactive walkthrough, the reference implementation, and a five-problem progression that this problem sits inside.

The approach

Greedy BFS by levels: track the end of the current jump's reach and the farthest reachable; when you hit the current end, take a jump and extend the boundary. Each "level" is one jump.

AspectValue
PatternGreedy
Recognise it byFewest jumps to the end.
Time complexityO(n)
Space complexityO(1)
DifficultyMedium

Who asks it

Companies known to ask this problem, from public LeetCode company-tag aggregations. A signal of where to expect it, not a guarantee.