Easy Method || Two Variable
IntuitionApproach

Initialize first_max as values[0]-1 (1 representing the distant to second index) and second_max as values[1].

result=first_max+second_max(=v


# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->


# Approach
<!-- Describe your approach to solving the problem. -->
1. Initialize first_max as values[0]-1 (1 representing the distant to second index) and second_max as values[1].

   * ```result=first_max+second_max(=values[0]+values[1]+0-1)```

2. Iterate the array from third element to last element in array.during this iteration :
    * one decrement the values of first_max and second_max variable 
    * if the current element is higher than first_max or second_max this variable will change to current element.
    * update the result also if it is higher than previouse result. 
3. return the result


![970c5fb0-2470-43f2-8873-57c3c3486f8b.jpeg](https://assets.leetcode.com/users/images/f14421ce-4190-458b-bc5a-6e61b3454db6_1735279990.8438628.jpeg)


# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
The solution processes each element of the array once, so the time complexity is 𝑂(𝑛), where n is the length of the array.
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
The solution uses only a few variables for tracking maximum values and results, so the space complexity is 𝑂(1)


# Code
```python3 []
class Solution:
    def maxScoreSightseeingPair(self, values: List[int]) -> int:
        
        if len(values)==2:
            return values[0]+values[1]-1
     
        first_max,second_max=values[0]-1,values[1]
        result=first_max+second_max

        for k in range(2,len(values)):
            first_max-=1
            second_max-=1
            
            if values[k]>first_max or values[k]>second_max:
                if first_max>second_max:
                    second_max=values[k]
                else:
                    first_max=values[k]

            result=max(result,first_max+second_max)

        return result


        
```
['Array', 'Python3']