1014-Best-Sightseeing-Pair

Sat 17 May 2025

https://leetcode.com/problems/best-sightseeing-pair

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def maxScoreSightseeingPair(self, A: List[int]) -> int:
    ans = 0
    bestPrev = 0

    for a in A:
      ans = max(ans, a + bestPrev)
      bestPrev = max(bestPrev, a) - 1

    return ans
new Solution().maxScoreSightseeingPair()

Score: 5

Category: leetcode