Skip to content

Commit 9163041

Browse files
authored
Merge pull request #3657 from SaiTeja-002/main
Create: 1423-maximum-points-you-can-obtain-from-cards.py
2 parents 7f17a22 + cf07c41 commit 9163041

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution:
2+
def maxScore(self, cardPoints: List[int], k: int) -> int:
3+
n = len(cardPoints)
4+
5+
score = maxScore = sum(cardPoints[:k])
6+
7+
for i in range(1, k + 1):
8+
score += cardPoints[-i] - cardPoints[k - i]
9+
maxScore = max(maxScore, score)
10+
11+
return maxScore

0 commit comments

Comments
 (0)