C++ | DP | T-O(N) & S-O(1) | Short & crisp solution
\nclass Solution {\npublic:\n    //This question is very similar to buy and sell stock with only two transactions possible.    \n    int maxScoreSightseeingPair
```\nclass Solution {\npublic:\n    //This question is very similar to buy and sell stock with only two transactions possible.    \n    int maxScoreSightseeingPair(vector<int>& values) {\n        int ci=values[0], cj=0;\n        for(int i=1;i<values.size();i++){\n            cj=max(cj,ci+values[i]-i); //ci stores max value of values[i]+i\n            ci=max(ci,values[i]+i); //cj stores max value of ci + values[j]-j for j>i\n        }\n        return cj;\n    }\n};\n```
['Dynamic Programming', 'C', 'C++']