Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Jump Game

Medium
greedyarraydynamic-programming

You start at index 0 of array nums, where nums[i] is your maximum jump length from position i. Return true if you can reach the last index.

Input: one line of space-separated non-negative integers. Output: true or false.

Example 1
Input:
2 3 1 1 4
Output:
true

0→1→4.

Example 2
Input:
3 2 1 0 4
Output:
false

Index 3 is a trap.

Constraints

  • 1 ≤ nums.length ≤ 10^4
  • 0 ≤ nums[i] ≤ 10^5
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.