parent
7c0d640882
commit
597e987977
|
|
@ -89,7 +89,19 @@ Java:
|
||||||
|
|
||||||
|
|
||||||
Python:
|
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:
|
Go:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue