01 · Question
You are given an array nums. Each element represents your maximum jump length. Return the minimum number of jumps to reach the last index.
The array is nonempty, jump lengths are nonnegative, and reaching the last index is guaranteed.
02 · Analysis
Assume a nonempty array of nonnegative jump lengths and that the last index is reachable. Treat each jump count as a BFS layer of reachable positions. Scan the whole current layer to find the next farthest boundary; only then increment jumps. Do not count another jump after reaching the final index. Time O(n), auxiliary space O(1). Without the reachability guarantee, a boundary that cannot advance must report failure.