Skip to main content
Back to problems
Leetcode
Medium
Arrays
Greedy
Google
Meta
Jump Game

Determine whether you can reach the last index of an array by making jumps from each position.

Acceptance 0%
Problem Statement

Problem

You are given a 0-indexed integer array nums. Each element nums[i] represents the maximum number of steps you can jump forward from index i.

Starting at index 0, determine whether it is possible to reach the last index of the array.

Return true if the last index is reachable, otherwise return false.

Notes

  • You may jump any number of steps from 1 to nums[i].
  • You only move forward.
  • Reaching the last index exactly counts as success.

Input Format

  • An integer array nums where nums[i] is the maximum forward jump length from index i.

Output Format

  • Return a boolean indicating whether index nums.length - 1 is reachable from index 0.

Constraints

  • 1 <= nums.length
  • 0 <= nums[i]
  • The array length and values are assumed to fit typical interview/online-judge limits.
Examples
Sample cases returned by the problem API.

Example 1

Input

nums = [2,3,1,1,4]

Output

true

Explanation

From index 0, jump to index 1, then jump to the last index.

Example 2

Input

nums = [3,2,1,0,4]

Output

false

Explanation

You can reach index 3, but nums[3] = 0 prevents reaching index 4.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.