Easy solution for java


  • 2
    2

    //we can get that 4 must lose, 5,6,7 must win(because you can make the other at 4), and 8 must //lose(because the other will get 5,6,7) loop this ,you can get the result
    public boolean canWinNim(int n) {
    if(n%4==0) return false;
    return true;
    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.