Given an array of integers numbers
, starting at the first index of the array, each element in the array represents the maximum number of steps that can be jumped forward from that position.
Determine whether it is possible to arrive at the final index of the array, returning true
if it can be achieved and false
otherwise.
numbers: number[]
: An array of integersInput: numbers = [4,1,0,0,2,3]Output: trueExplanation: Jump from index 0 to 4 directly, then jump 1 step to the last index.
Input: numbers = [1,0,0,0]Output: falseExplanation: Can only jump to index 1 from index 0. Maximum jump length of index 1 is 0, making it impossible to reach the last index.
Input: numbers = [2,3,1,1,4]Output: trueExplanation: Jump 1 step from index 0 to 1 and then 3 steps to the last index.
numbers.length
<= 10,000numbers[i]
<= 100,000Given an array of integers numbers
, starting at the first index of the array, each element in the array represents the maximum number of steps that can be jumped forward from that position.
Determine whether it is possible to arrive at the final index of the array, returning true
if it can be achieved and false
otherwise.
numbers: number[]
: An array of integersInput: numbers = [4,1,0,0,2,3]Output: trueExplanation: Jump from index 0 to 4 directly, then jump 1 step to the last index.
Input: numbers = [1,0,0,0]Output: falseExplanation: Can only jump to index 1 from index 0. Maximum jump length of index 1 is 0, making it impossible to reach the last index.
Input: numbers = [2,3,1,1,4]Output: trueExplanation: Jump 1 step from index 0 to 1 and then 3 steps to the last index.
numbers.length
<= 10,000numbers[i]
<= 100,000console.log()
statements will appear here.