Skip to content

3222. Find the Winning Player in Coin Game 👍

  • Time: $O(1)$
  • Space: $O(1)$
1
2
3
4
5
6
class Solution {
 public:
  string losingPlayer(int x, int y) {
    return min(x, y / 4) % 2 == 0 ? "Bob" : "Alice";
  }
};
1
2
3
4
5
class Solution {
  public String losingPlayer(int x, int y) {
    return Math.min(x, y / 4) % 2 == 0 ? "Bob" : "Alice";
  }
}
1
2
3
class Solution:
  def losingPlayer(self, x: int, y: int) -> str:
    return 'Bob' if min(x, y // 4) % 2 == 0 else 'Alice'