Skip to content

1753. Maximum Score From Removing Stones 👍

  • Time: $O(n)$
  • Space: $O(1)$
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
class Solution {
 public:
  int maximumScore(int a, int b, int c) {
    // Max <= min + mid
    const int x = (a + b + c) / 2;
    // Max > min + mid
    const int y = a + b + c - max({a, b, c});
    return min(x, y);
  }
};
1
2
3
4
5
6
7
8
9
class Solution {
  public int maximumScore(int a, int b, int c) {
    // Max <= min + mid
    final int x = (a + b + c) / 2;
    // Max > min + mid
    final int y = a + b + c - Math.max(a, Math.max(b, c));
    return Math.min(x, y);
  }
}