Leetcode 55 跳躍遊戲 【貪心算法】

1.思路 1)maxpos爲已經經過的部分的數組所能達到的最遠處 2)遍歷,每次都更新maxpos,其爲之前maxpos和i+nums[i]的最大值 2.代碼 class Solution: def canJump(self, nums): """ :type nums: List[int] :rtype: bool """ maxpos
相關文章
相關標籤/搜索