Skip to content

Commit 26125ae

Browse files
committed
Create 1014.最佳观光组合.js
1 parent 5937b27 commit 26125ae

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

1014.最佳观光组合.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param {number[]} A
3+
* @return {number}
4+
*/
5+
var maxScoreSightseeingPair = function(A) {
6+
let result = A[0] + A[1] - 1;
7+
let max = A[0];
8+
for (let i = 1; i < A.length; i++) {
9+
result = Math.max(result, max + A[i] - i);
10+
max = Math.max(max, A[i] + i);
11+
}
12+
return result;
13+
};

0 commit comments

Comments
 (0)