1753. Maximum Score From Removing Stones
Read the full problem statement on LeetCode.
Difficulty: medium Acceptance: 68% Topics: Math, Greedy, Heap (Priority Queue)
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(1)
# Space: O(1)
class Solution(object):
def maximumScore(self, a, b, c):
"""
:type a: int
:type b: int
:type c: int
:rtype: int
"""
# assumed c is the max size
# case1: a+b > c
# => (a+b-c)//2 + c = (a+b+c)//2 < a+b
# case2: a+b <= c
# => a+b <= (a+b+c)//2
return min((a+b+c)//2, a+b+c - max(a, b, c))
Solution from kamyu104/LeetCode-Solutions · MIT
Similar questions