Skip to content

Commit ec77a54

Browse files
authored
Create maximum-score-from-removing-stones.cpp
1 parent 0074fe7 commit ec77a54

File tree

1 file changed

+14
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)