Skip to content

Resource · Guide or article

Jump Game

Takes the reachability question on an array of maximum jump lengths and refines it step by step from backtracking to a greedy single pass. A clear model of how memoization turns into bottom-up DP and then into a greedy shortcut.

Reviewed

Open the original: Jump Game (opens the original site in a new tab)

Add to a roadmap

Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.

Source content: English

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you are able to reach the last index. We call a position in the array a "good index" if starting at that position, we can reach the last index. Otherwise, that index is called a "bad index". The problem then reduces to whether or not index 0 is a "good index".

PrepKit overview

PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.

Suited to
The source does not state a level
Format
Lesson

What it covers

  • Problem statement with one reachable and one unreachable example
  • Frames the problem as deciding whether index 0 is a good index
  • Backtracking at O(2^n) time and O(n) auxiliary space
  • Top-down memoization with GOOD, BAD and UNKNOWN states, then bottom-up DP, both O(n^2) time
  • Greedy pass tracking the left-most good position, O(n) time and O(1) space

How to use it

PrepKit study advice, not a claim made by the source.

Implement all four versions in order and run them on both examples. Then, without notes, explain why the bottom-up table only ever needs its left-most good index.

Scope and limitations

Code is in separate JavaScript files in the folder, not on this page. Only the reachability variant is covered, not the minimum-jumps follow-up.

Access and format

README on GitHub in trekhleb/javascript-algorithms (MIT), linking four solution files. English, free.

Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88

Evidence behind this overview
  • src/algorithms/uncategorized/jump-game/README.md

Pages that include this

Get the PrepKit newsletter

Optional. You don't need it to use PrepKit.

How we handle your email