class Solution: def canJump(self, nums: List[int]) -> bool: if len(nums) == 1:return True i = 0;j = i for i in range(100000): if j > i+nums[i]:pass else:j = i+nums[i] i+=1 if i > j:break if j >= len(nums)-1:return True return False
You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position.
Return true if you can reach the last index, or false otherwise.
nums.length <= 104
浙公網安備 33010602011771號