Leetcode

Nim Game

  • Time:O(1)
  • Space:O(1)

C++

class Solution {
 public:
  bool canWinNim(int n) {
    return n % 4 != 0;
  }
};

JAVA

class Solution {
  public boolean canWinNim(int n) {
    return n % 4 != 0;
  }
}

Python

class Solution:
  def canWinNim(self, n: int) -> bool:
    return n % 4 != 0