Skip to main content

55. Jump Game

mediumAsked at Netflix

Given an array where each element is the max jump length from that index, determine if you can reach the last index. Netflix asks this on the greedy round — they want the 'track furthest reachable' one-pass solution, not DP backtracking.

By Alex Chen, Founder, InterviewChamp.AI · Last verified

Source citations

Public interview reports confirming this problem appears in Netflix loops.

  • Glassdoor (2026-Q1)Netflix L4 onsite reports cite Jump Game as the greedy warmup before Jump Game II.
  • Blind (2025-12)Netflix SWE writeups describe 'one-pass furthest reachable' narration as the signal.

Problem

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.

Constraints

  • 1 <= nums.length <= 10^4
  • 0 <= nums[i] <= 10^5

Examples

Example 1

Input
nums = [2,3,1,1,4]
Output
true

Explanation: 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

Explanation: You will always arrive at index 3 with a max jump of 0.

Approaches

1. DP — can-reach[i] from the right

Build a boolean array dp[i] = 'can reach the end from i'. dp[n-1] = true. Iterate right-to-left, set dp[i] = true if any j in [i+1, i+nums[i]] has dp[j] = true.

Time
O(n^2)
Space
O(n)
function canJumpDP(nums) {
  const n = nums.length;
  const dp = new Array(n).fill(false);
  dp[n - 1] = true;
  for (let i = n - 2; i >= 0; i--) {
    const reach = Math.min(i + nums[i], n - 1);
    for (let j = i + 1; j <= reach; j++) {
      if (dp[j]) { dp[i] = true; break; }
    }
  }
  return dp[0];
}

Tradeoff: Correct and easier to derive but O(n^2). Mention it as the intermediate step before greedy.

2. Greedy furthest reachable (optimal)

Track furthest = the furthest index reachable so far. Walk left-to-right; if i > furthest, return false. Otherwise update furthest = max(furthest, i + nums[i]). Return true at the end.

Time
O(n)
Space
O(1)
function canJump(nums) {
  let furthest = 0;
  for (let i = 0; i < nums.length; i++) {
    if (i > furthest) return false;
    furthest = Math.max(furthest, i + nums[i]);
    if (furthest >= nums.length - 1) return true;
  }
  return true;
}

Tradeoff: Single pass, O(1) space. The invariant is: 'furthest is the maximum index reachable using any combination of jumps from positions 0..i'.

Netflix-specific tips

Netflix interviewers expect the greedy version on this one but want you to first state the invariant: 'furthest = max index reachable from any 0..i'. If you go DP first, narrate the simplification: 'I don't actually need to track which exact positions are reachable, just the rightmost.' That bridge is what they're listening for.

Common mistakes

  • Returning false too eagerly — only return false when i > furthest, not when nums[i] === 0.
  • Updating furthest using nums[i] alone instead of i + nums[i].
  • Doing recursive top-down DP without memo — exponential blowup.

Follow-up questions

An interviewer at Netflix may pivot to one of these next:

  • Jump Game II (LC 45) — minimum number of jumps to reach the end.
  • Jump Game III (LC 1306) — variant where nums[i] is a jump distance left OR right.
  • Jump Game IV (LC 1345) — BFS variant with teleport edges.

Solve it now

Free. No sign-up. Python and JavaScript run instantly in your browser.

Output

Press Run or Cmd+Enter to execute

FAQ

Why does greedy work here when DP feels safer?

Because 'reachability' has an optimal substructure: if you can reach any index in [0..i], you can reach exactly the union of jump destinations from those indices. That union is captured by max(j + nums[j] for j in [0..i]) — a single number, no per-index tracking needed.

Is this the same as Jump Game II?

No. This problem asks IF you can reach the end (boolean). Jump Game II asks the MINIMUM number of jumps, which needs a different greedy (BFS-like, tracking current frontier and next frontier).

Free learning resources

Curated free links for this problem.

Practice these live with InterviewChamp.AI

Drill Jump Game and other Netflix interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.

Practice these live with InterviewChamp.AI →