[Java/C++/Python] One Pass, O(1) space
Soluton 1\nCount the current best score in all previous sightseeing spot.\nNote that, as we go further, the score of previous spot decrement.\n\ncur will record
# **Soluton 1**\nCount the current best score in all previous sightseeing spot.\nNote that, as we go further, the score of previous spot decrement.\n\n`cur` will record the best score that we have met.\nWe iterate each value `a` in the array `A`,\nupdate `res` by `max(res, cur + a)`\n\nAlso we can update `cur` by `max(cur, a)`.\nNote that when we move forward,\nall sightseeing spot we have seen will be 1 distance further.\n\nSo for the next sightseeing spot `cur = Math.max(cur, a) - 1`\n\nThere is a feeling that,\n"A near neighbor is better than a distant cousin."\n\n**Java:**\n```java\n    public int maxScoreSightseeingPair(int[] A) {\n        int res = 0, cur = 0;\n        for (int a: A) {\n            res = Math.max(res, cur + a);\n            cur = Math.max(cur, a) - 1;\n        }\n        return res;\n    }\n```\n\n**C++:**\n```cpp\n    int maxScoreSightseeingPair(vector<int>& A) {\n        int res = 0, cur = 0;\n        for (int a: A) {\n            res = max(res, cur + a);\n            cur = max(cur, a) - 1;\n        }\n        return res;\n    }\n```\n\n**Python:**\n```py\n    def maxScoreSightseeingPair(self, A):\n        cur = res = 0\n        for a in A:\n            res = max(res, cur + a)\n            cur = max(cur, a) - 1\n        return res\n```\n**Python 1-line:**\n```py\n    def maxScoreSightseeingPair(self, A):\n        return reduce(lambda (r, c), a: [max(r, c + a), max(c, a) - 1], A, [0, 0])[0]\n```\n<br>\n\n# **Complexity**:\nOne pass,\nTime `O(N)`,\nSpace `O(1)`.\n<br>\n\n# **Soluton 2**\n**Java**\n```java\n    public int maxScoreSightseeingPair(int[] A) {\n        int res = 0, imax = 0;\n        for(int i = 0; i < A.length; ++i) {\n            res = Math.max(res, imax + A[i] - i);\n            imax = Math.max(imax, A[i] + i);\n        }\n        return res;\n    }\n```\n**C++**\n```cpp\n    int maxScoreSightseeingPair(vector<int>& A) {\n        int res = 0, imax = 0;\n        for(int i = 0; i < A.size(); ++i) {\n            res = max(res, imax + A[i] - i);\n            imax = max(imax, A[i] + i);\n        }\n        return res;\n    }\n```\n**Python**\n```py\n    def maxScoreSightseeingPair(self, A):\n        res = imax = 0\n        for i, a in enumerate(A):\n            res = max(res, imax + A[i] - i)\n            imax = max(imax, A[i] + i)\n        return res\n\n```
[]