Update 0055.跳跃游戏.md

增加Python for循环版
This commit is contained in:
roylx
2022-11-15 11:01:24 -07:00
committed by GitHub
parent 4261d96a14
commit 6fb61ead0b

View File

@ -119,6 +119,18 @@ class Solution:
return False return False
``` ```
```python
## for循环
class Solution:
def canJump(self, nums: List[int]) -> bool:
cover = 0
if len(nums) == 1: return True
for i in range(len(nums)):
cover = max(i + nums[i], cover)
if cover >= len(nums) - 1: return True
return False
```
### Go ### Go
```Go ```Go
func canJUmp(nums []int) bool { func canJUmp(nums []int) bool {