Jump Game
Problem statement
You are given an array nums. You start at index 0, and nums[i] is the maximum number of positions you may jump forward from index i.
Return true if you can reach the final index. Otherwise, return false.
Function
canJump(nums: int[]) → booleanExamples
Example 1
nums = [2,3,1,1,4]return = trueJump from index 0 to index 1, then from index 1 to the final index.
Example 2
nums = [3,2,1,0,4]return = falseEvery route reaches index 3, whose jump length is zero, before the final index.
Example 3
nums = [0]return = trueThe starting index is already the final index.
Constraints
1 <= nums.length <= 100000.0 <= nums[i] <= 100000.