Skip to content

Commit 3ebe48c

Browse files
authored
Create 1021-best-sightseeing-pair.js
1 parent 49114cc commit 3ebe48c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

1021-best-sightseeing-pair.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @param {number[]} A
3+
* @return {number}
4+
*/
5+
const maxScoreSightseeingPair = function(A) {
6+
let res = 0, cur = 0;
7+
for (let a of A) {
8+
res = Math.max(res, cur + a);
9+
cur = Math.max(cur, a) - 1;
10+
}
11+
return res;
12+
};

0 commit comments

Comments
 (0)