Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

185. Jump Game

MediumDay 55 of 60Greedy & Intervals

You stand on the first index of an array nums. Each value nums[i] is the longest jump you may make from index i (you can also jump shorter). Return true if you can reach the last index, otherwise false.

Example 1
Input: nums = [2,3,1,1,4]
Output: true
Jump 1 step to index 1, then 3 steps to the end.
Example 2
Input: nums = [3,2,1,0,4]
Output: false
Every route lands on index 3, whose value is 0.
Constraints
  • 1 <= nums.length <= 10^4
  • 0 <= nums[i] <= 10^5
Hints
Frequently asked at: Amazon, Microsoft, Google, Adobe
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min