Python | One Pass | O(N) | with comments
\nclass Solution:\n    def maxScoreSightseeingPair(self, values: List[int]) -> int:\n        # maintain the current max reference variable and answer variable\n
```\nclass Solution:\n    def maxScoreSightseeingPair(self, values: List[int]) -> int:\n        # maintain the current max reference variable and answer variable\n        mx_ref,ans = values[0],0\n        # at every index update both variables as below\n        for value in values[1:]:\n            # 8 at index 0 will become 7 at index 1 and 6 at index 2, so we can always keep a track of current max by comparing values[i-1]-1 with values[i].\n            ans = max(ans, value+mx_ref-1)\n            mx_ref = max(mx_ref-1,value)\n        return ans\n```
[]