C++ O(N) Solution With Explanation
We will make a variable currVal which will store current maximum A[i]+i-j\n1. we will initialize currVal = A[i]\n2. we will keep it decrementing by 1 which is e
We will make a variable currVal which will store current maximum A[i]+i-j\n1. we will initialize currVal = A[i]\n2. we will keep it decrementing by 1 which is equivalent to i-j\n3. if currVal is smaller than A[i], we update currVal=A[i]\n4. we find sum of A[i] and currVal for every index and return maximum value\n\n```\nclass Solution {\npublic:\n    int maxScoreSightseeingPair(vector<int>& A) {\n        int currVal=A[0];\n        int currsum;int maxsum=0;\n        int n=A.size();\n        for(int i=1;i<n;i++)\n        {\n            currVal--;\n            currsum=A[i]+currVal;\n            maxsum=max(currsum,maxsum);\n            currVal=max(currVal,A[i]);\n        }\n        return maxsum;\n    }\n};\n```
[]