mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
Update 0055.跳跃游戏.md
增加Python for循环版
This commit is contained in:
@ -119,6 +119,18 @@ class Solution:
|
||||
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
|
||||
func canJUmp(nums []int) bool {
|
||||
|
Reference in New Issue
Block a user