Dodomeki
Sign in

35. Possible Jump

Easy

You start at the first position of alcances. Each value indicates the maximum number of steps you can move forward from that position. Return true if it is possible to reach the last position, and false otherwise.

Example 1
Input: alcances = [2, 3, 1, 1, 4]
Output: true
Example 2
Input: alcances = [3, 2, 1, 0, 4]
Output: false
Explanation: The reach stops one position before the last.
Constraints
  • 1 <= alcances.length <= 10^5
  • 0 <= alcances[i] <= 10^5
ArraysGreedy
Caso 1
alcances =
[2,3,1,1,4]
Expected =
true
Caso 2
alcances =
[3,2,1,0,4]
Expected =
false
Caso 3
alcances =
[0]
Expected =
true

Run checks these 3 cases. Submit runs all 6, including hidden ones.