63. Jump Game
Medium · Dynamic Programming
You are given an integer array `nums` where you are initially positioned at the first index. Each element in the array represents your maximum jump length from that position.
Determine if you can reach the last index of the array. You may jump from index `i` to any index `j` where `i < j <= i + nums[i]`.
Return `true` if you can reach the last index, otherwise return `false`.
Examples
Example 1 Input: nums = [2, 3, 1, 1, 4] Output: true Explanation: Jump 1 step from index 0 to 1, then jump 3 steps from index 1 to the last index (index 4).
Example 2 Input: nums = [3, 2, 1, 0, 4] Output: false Explanation: You will always arrive at index 3, no matter what. Its maximum jump length is 0, so you can never reach the last index.
Constraints
- Standard input/output constraints apply