C++ O(n), best time to buy and sell stock
Intuition\nIt\'s similar to Best Time to Buy and Sell Stock, but instead of min price, we track max value, and our max value decays every step due to the distan
## Intuition\nIt\'s similar to [Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/), but instead of min price, we track max value, and our max value decays every step due to the distance penalty.\n## Solution\n- Track the maximum value of ```A[i]``` as ```max_i```.\n- Every turn, decrement ```max_i```to account for ```j - i```.\n- Track and return the maximum score.\n```\nint maxScoreSightseeingPair(vector<int>& A, int res = 0) {\n  for (auto j = 1, max_i = A[0] - 1; j < A.size(); ++j, --max_i) {\n    res = max(res, A[j] + max_i);\n    max_i = max(max_i, A[j]);\n  }\n  return res;\n}\n```\n## Complexity Analysis\nRuntime: *O(n)*\nMemory: *O(1)*
[]