首页
Java
登录
6mi
u
盘
搜
搜 索
Java
LeetCode 55. Jump Game
LeetCode 55. Jump Game
xiaoxiao
2021-02-28
12
题目
思路
维护一个最右index,遍历数组的同时更新最右index即可。
代码
class
Solution
:
def
canJump
(self, nums)
:
""" :type nums: List[int] :rtype: bool """
right =
0
for
i
in
range(len(nums)):
if
i <= right: right = max(right, i + nums[i])
return
right >= len(nums) -
1
转载请注明原文地址: https://www.6miu.com/read-2602185.html
技术
最新回复
(
0
)