Update 0055.跳跃游戏.md

python for循环版,添加了更新cover的条件
This commit is contained in:
roylx 2022-11-15 11:05:39 -07:00 committed by GitHub
parent 6fb61ead0b
commit c0f1f13669
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -126,6 +126,7 @@ class Solution:
cover = 0
if len(nums) == 1: return True
for i in range(len(nums)):
if i <= cover:
cover = max(i + nums[i], cover)
if cover >= len(nums) - 1: return True
return False