Skip to content

Commit 17814c2

Browse files
committed
Added Python solution for "Maximum Points You Can Obtain from Cards"
1 parent 674aa95 commit 17814c2

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
"""
6+
Time: O(n)
7+
Memory: O(1)
8+
"""
9+
10+
def maxScore(self, cards: List[int], k: int) -> int:
11+
n = len(cards)
12+
size = n - k
13+
min_window = window = sum(cards[:size])
14+
15+
for i in range(size, n):
16+
window += cards[i] - cards[i - size]
17+
min_window = min(min_window, window)
18+
19+
return sum(cards) - min_window
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)