-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy path1014.py
26 lines (26 loc) · 971 Bytes
/
1014.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
__________________________________________________________________________________________________
sample 460 ms submission
class Solution:
def maxScoreSightseeingPair(self, A: List[int]) -> int:
current, answer = 0, 0
for a in A:
if current + a > answer:
answer = current + a
if a > current:
current = a
# Take care of j - i
current -= 1
return answer
__________________________________________________________________________________________________
sample 16636 kb submission
class Solution:
def maxScoreSightseeingPair(self, A: List[int]) -> int:
res = cur = 0
i = 0
for j in range(len(A)):
res = max(res, cur+A[j]+i-j)
if cur+i -j < A[j]:
cur = A[j]
i = j
return res
__________________________________________________________________________________________________