Explanation
Jump Game is a Medium interview problem tagged [Array, Greedy, Dynamic Programming]. The winning approach is typically **Greedy**.
#55
You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position.
Return true if you can reach the last index, or false otherwise.
Example 1
Input: nums = [2,3,1,1,4]
Output: true
Jump 1 step from index 0 to 1, then 3 steps to the last index.
Example 2
Input: nums = [3,2,1,0,4]
Output: false
You always arrive at index 3 with jump length 0.
Jump Game is a Medium interview problem tagged [Array, Greedy, Dynamic Programming]. The winning approach is typically **Greedy**.
When an exchange argument holds, greedy beats heavier DP.
Sort by a key, then make the locally best choice that preserves a global invariant.
Pattern-level skeleton only — not this problem’s exact answer. Adapt it to the statement.
Time: O(n log n) or O(n)
Space: O(n)
Before coding, restate the problem, name the pattern (Greedy), and write the invariant or DP state in one sentence.
Got it?
Mark #55 Jump Game as understood when the pattern clicks.