leetcode-1014-最佳观光组合

 

 解:O(N)

class Solution:
    def maxScoreSightseeingPair(self, A: List[int]) -> int:
        left, res = A[0], -1
        for j in range(1, len(A)):
            res = max(res, left + A[j] - j)
            left = max(left, A[j] + j)
        return res

 

posted @ 2020-06-17 23:48  oldby  阅读(133)  评论(0编辑  收藏  举报