Skip to content

Commit 1a06639

Browse files
authored
Create best-sightseeing-pair.py
1 parent 7d7cf13 commit 1a06639

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Python/best-sightseeing-pair.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def maxScoreSightseeingPair(self, A):
6+
"""
7+
:type A: List[int]
8+
:rtype: int
9+
"""
10+
result, curr = 0, 0
11+
for x in A:
12+
result = max(result, curr+x)
13+
curr = max(curr, x)-1
14+
return result

0 commit comments

Comments
 (0)