ntree.aiJump Game
Jump Game
mediumsolvedattempted
You start at the first index of an array nums. Each nums[i] is the longest jump you can make from index i: you may move forward by any number of steps from 0 to nums[i].
Return true if you can reach the last index.
Example 1:
Input: nums = [2, 3, 1, 1, 4]
Output: true
Explanation: jump 1 step to index 1, then 3 steps to the last index.
Example 2:
Input: nums = [3, 2, 1, 0, 4]
Output: false
Explanation: every path lands on index 3, whose jump length is 0.
Constraints:
1 <= length of nums <= 10^40 <= nums[i] <= 10^5
def canJump(nums: list[int]) -> bool: pass Press Visualise to step through your code.