Skip to content

Commit 0298dc2

Browse files
authored
Create maximum-score-from-removing-stones.py
1 parent ec77a54 commit 0298dc2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Time: O(1)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def maximumScore(self, a, b, c):
6+
"""
7+
:type a: int
8+
:type b: int
9+
:type c: int
10+
:rtype: int
11+
"""
12+
# assumed c is the max size
13+
# case1: a+b > c
14+
# => (a+b-c)//2 + c = (a+b+c)//2 < a+b
15+
# case2: a+b <= c
16+
# => a+b <= (a+b+c)//2
17+
return min((a+b+c)//2, a+b+c - max(a, b, c))

0 commit comments

Comments
 (0)