Beats 97.03% || Java || Greedy || Easy approach ✅ ✅ ✅ 
This code solves the problem of finding the maximum score of a sightseeing pair, where the score of a pair (i, j) is defined as:Intuitionvalues[i]+i represents
This code solves the problem of finding the maximum score of a sightseeing pair, where the score of a pair (i, j) is defined as:

                  values[i]+values[j]+i−j
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
`values[i]+i` represents how good the left element 
`values[j]−j `represents how good the right element 

Combining these,
`values[i]+i+values[j]−j `
 we want to maximize this score
- Get the maximum till that point that wil be `max(max,values[i]+i)`
- Check the score with current and prev res `max(max+values[i]-i,res)`
# Approach
<!-- Describe your approach to solving the problem. -->
- Start with the first value as the best left element 
- Set res to the lowest possible value.
- For each j, calculate the score of the pair `(i,j)` using the current best max.
- Update max to keep track of the best left-side value for future pairs.
- After checking all pairs, the maximum score is stored in res.
# Complexity
- Time complexity: $$O(n)$$ 
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: $$O(1)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int maxScoreSightseeingPair(int[] values) {
        int res=Integer.MIN_VALUE;
        int max=values[0];
        int n=values.length;
        for(int i=1;i<n;i++){
            res=Math.max(max+values[i]-i,res);
            if(max < values[i]+i){
                max=values[i]+i;
            }
        }
        return res;
        
    }
}
```
['Java']