use hashmap sorting
IntuitionApproachComplexity

Time complexity:
O(nlogn)


Space complexity:
o(n)

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

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
O(nlogn)

- Space complexity:
o(n)

# Code
```cpp []
class Solution {
public:
    int maxScoreSightseeingPair(vector<int>& values) {
       map<int,int>mp;
       int maxi = INT_MIN;
       for(int i=0;i<values.size();i++){
           if(mp.size()>0){
              maxi = max(maxi,max(mp.begin()->first-i+values[i],mp.rbegin()->first-i+values[i]));
           }
           mp[i+values[i]] = i;
       }
       return maxi;
    }
};
```
['Hash Table', 'Sorting', 'C++']