Skip to content

292. Nim Game 👎

  • Time: $O(1)$
  • Space: $O(1)$
1
2
3
4
5
6
class Solution {
 public:
  bool canWinNim(int n) {
    return n % 4 != 0;
  }
};
1
2
3
4
5
class Solution {
  public boolean canWinNim(int n) {
    return n % 4 != 0;
  }
}
1
2
3
class Solution:
  def canWinNim(self, n: int) -> bool:
    return n % 4 != 0