DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
medium
Array

Jump Game

**Problem Statement:** You are given an integer array `nums`. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position. Return `true` if you can reach the last index, or `false` otherwise. **Hint / Expected Approach:** Greedy: track max reachable index **Edge Cases to Consider:** - (1) All zeros except last - (2) Single element - (3) First element zero

Examples

Example 1
Input: [2,3,1,1,4]
Output: True
Example 2
Input: [3,2,1,0,4]
Output: False
Example 3
Input: [0]
Output: True

Constraints

  • ▪1 <= nums.length <= 10^4
  • ▪-10^9 <= nums[i] <= 10^9
  • ▪Time complexity should be O(n) or O(n log n)

Watch Out For Edge Cases

  • ▪All zeros except last
  • ▪Single element
  • ▪First element zero
Frequently Asked At
AmazonMicrosoftMetaUberZomato