diff --git a/problems/0055.跳跃游戏.md b/problems/0055.跳跃游戏.md index 23357f21..0ed03b07 100644 --- a/problems/0055.跳跃游戏.md +++ b/problems/0055.跳跃游戏.md @@ -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 {