Loading problem...
You are given an integer array jumpCapacity where you start at position 0 (the first element). Each element in the array represents the maximum number of positions you can advance forward from that location.
Your objective is to determine whether it is possible to reach the final position (the last element of the array) starting from the initial position.
At any position i, you can move to any position from i + 1 to i + jumpCapacity[i] (inclusive), as long as the destination position is within the bounds of the array. If jumpCapacity[i] = 0, you cannot move forward from that position.
Return true if you can reach the last position, or false otherwise.
jumpCapacity = [2,3,1,1,4]trueOne possible path: Start at index 0 (value 2), jump 1 step to index 1 (value 3), then jump 3 steps directly to index 4 (the final position). Multiple valid paths exist.
jumpCapacity = [3,2,1,0,4]falseEvery path leads to index 3, which has value 0. Since you cannot jump forward from index 3, you are trapped and cannot reach the final position at index 4.
jumpCapacity = [1,2,3]trueStart at index 0 (value 1), jump 1 step to index 1 (value 2), then jump 1 or 2 steps to reach index 2 (the final position).
Constraints