Skip to main content
All Questions

Can Jump - Given an array of non-negative integers, you're initially at the first index. Each element represents your maximum jump length at that position. Determine if you can reach the last index.

Medium
Unlock detailed company stats for this questionUpgrade
https://leetcode.com/problems/jump-game/description/

You start at index 0 of an integer array nums. Each element is the maximum number of steps you can jump forward from that position. Return true if you can reach the last index, and false otherwise.

Example 1

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

Jump 1 step to index 1, then 3 steps to the last index.

Example 2

Input: nums = [3, 2, 1, 0, 4] Output: false

Every path lands on index 3, whose jump length is 0, so you can never get past it.

Constraints

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

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.