Update 0055.跳跃游戏.md

Added python version code
This commit is contained in:
LiangDazhu
2021-05-14 00:10:35 +08:00
committed by GitHub
parent 5b6d47dba9
commit c80f574f5c

View File

@ -89,7 +89,19 @@ Java
Python
```python
class Solution:
def canJump(self, nums: List[int]) -> bool:
cover = 0
if len(nums) == 1: return True
i = 0
# python不支持动态修改for循环中变量,使用while循环代替
while i <= cover:
cover = max(i + nums[i], cover)
if cover >= len(nums) - 1: return True
i += 1
return False
```
Go