Build Intuition with Diagram | Simple Solution | S(n): O(1) | T(n) : O(n)
Here it is said that we have to maximize the value of values[i] + values[j] - ( j - i ),  so if we reqarrange it a little bit we will get something like this ( 
Here it is said that we have to maximize the value of **values[i] + values[j] - ( j - i )**,  so if we reqarrange it a little bit we will get something like this **( values[i] + i ) + ( values[j] - j )**\nNow, as we can see in the below diagram , we have to **create 2 arrays with modified values** and for each **( values[j] - j )** find the maximum   **( values[i] + i )** , where **i < j**.\n\n![image](https://assets.leetcode.com/users/images/43b7510f-e9eb-45dc-baa9-48d947f48fd9_1646456721.271394.png)\n\nWe can use either a PriorityQueue to keep the max till now , or simply keep a variable that tracks the **max(values[i] + i)** where **i < j**,\n\n```\nclass Solution {\n    public int maxScoreSightseeingPair(int[] values) {\n        int max = -1;\n        int currMax = values[0];\n        for(int i =1;i<values.length;i++){\n            int tempMax = currMax + (values[i] - i);\n            max = Math.max(tempMax, max);\n            currMax = Math.max(currMax, values[i] + i);\n        }\n        return max;\n    }\n}\n```\n\nDo Upvote if you like the solution.\nHappy Coding !!
['Dynamic Programming', 'Java']