Maximum Score From Removing Stones LeetCode solution in Java

1
class Solution {
2
public int maximumScore(int a, int b, int c) {
3
// Make sure a <= b <= c
4
if (a > b) return maximumScore(b, a, c);
5
if (b > c) return maximumScore(a, c, b);
6

7
// if sum of smallest numbers [a+b] is less than c, then we can a + b pairs with the c
8
if (a + b <= c) return a + b;
9

10
// if sum of smallest numbers is greater than c, then we can (a+b)/2 pairs after making c empty
11
return c + (a + b - c) / 2;
12
}
13
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0