✅✅Faster || Easy To Understand || C++ Code
Optimized\n\n Time Complexity :- O(N)\n\n Space Complexity :- O(1)\n\n\nclass Solution {\npublic:\n    int maxScoreSightseeingPair(vector<int>& arr) {\n        
* ***Optimized***\n\n* ***Time Complexity :- O(N)***\n\n* ***Space Complexity :- O(1)***\n\n```\nclass Solution {\npublic:\n    int maxScoreSightseeingPair(vector<int>& arr) {\n        \n        int n = arr.size();\n      \n        int maxi = INT_MIN;\n        \n        // left_max will keep track of max. value of (arr[i] + i)\n        \n        int left_max = arr[0];\n        \n        for(int i = 1; i < n; i++)\n        {\n            // find sum\n            \n            int sum = left_max + arr[i] - i;\n            \n            // update maxi\n            \n            maxi = max(maxi, sum);\n            \n            // update left_max\n            \n            left_max = max(left_max, arr[i] + i);\n        }\n        \n        return maxi;\n    }\n};\n```
['Dynamic Programming', 'Greedy', 'C', 'C++']