Skip to content

Commit a6a3df8

Browse files
solves 3222: Find the Winning Player in Coin Game in java
1 parent b32da14 commit a6a3df8

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -927,5 +927,5 @@
927927
| 3206 | [Alternating Groups I](https://leetcode.com/problems/alternating-groups-i) | [![Java](assets/java.png)](src/AlternatingGroupsI.java) | |
928928
| 3210 | [Find the Encrypted String](https://leetcode.com/problems/find-the-encrypted-string) | [![Java](assets/java.png)](src/FindTheEncryptedString.java) | |
929929
| 3216 | [Lexicographically Smallest String After a Swap](https://leetcode.com/problems/lexicographically-smallest-string-after-a-swap) | [![Java](assets/java.png)](src/LexicographicallySmallestStringAfterASwap.java) | |
930-
| 3222 | [Find the Winning Player in Coin Game](https://leetcode.com/problems/find-the-winning-player-in-coin-game) | | |
930+
| 3222 | [Find the Winning Player in Coin Game](https://leetcode.com/problems/find-the-winning-player-in-coin-game) | [![Java](assets/java.png)](src/FindTheWinningPlayerInCoinGame.java) | |
931931
| 3226 | [Number of Bit Changes to Make Two Integers Equal](https://leetcode.com/problems/number-of-bit-changes-to-make-two-integers-equal) | | |
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// https://leetcode.com/problems/find-the-winning-player-in-coin-game
2+
// T: O(1)
3+
// S: O(1)
4+
5+
public class FindTheWinningPlayerInCoinGame {
6+
public String losingPlayer(int x, int y) {
7+
final int maxGames10CentCoins = y / 4;
8+
final int maxGamesPossible = Math.min(x, maxGames10CentCoins);
9+
return maxGamesPossible % 2 == 0 ? "Bob" : "Alice";
10+
}
11+
}

0 commit comments

Comments
 (0)