author: Blankj blog : http://blankj.com time : 2020/06/18 desc :
| 9 | * </pre> |
| 10 | */ |
| 11 | public class Solution { |
| 12 | |
| 13 | public int maxScoreSightseeingPair(int[] A) { |
| 14 | int ans = 0, cur = A[0] + 0; |
| 15 | for (int j = 1; j < A.length; j++) { |
| 16 | ans = Math.max(ans, cur + A[j] - j); // 计算当前最大得分 |
| 17 | cur = Math.max(cur, A[j] + j); // 更新最大的 A[i] + i |
| 18 | } |
| 19 | return ans; |
| 20 | } |
| 21 | |
| 22 | public static void main(String[] args) { |
| 23 | Solution solution = new Solution(); |
| 24 | int[] A = new int[]{8, 1, 5, 2, 6}; |
| 25 | System.out.println(solution.maxScoreSightseeingPair(A)); |
| 26 | } |
| 27 | } |
nothing calls this directly
no outgoing calls
no test coverage detected