This should be a math not algorithm problem.


  • 3
    R

    Just one line code can solve this problem.

    return !(n%4==0);
    

    First step try to make the total amount to be a multiple of 4, and no matter how many stones your opponent takes, just make the total to be a multiple of 4. Finally there will be 4 stones, and obviously you will win at the time.
    This problem is a math trick game rather than an algorithm problem.


  • 0
    O

    it's tagged as a brainteaser


Log in to reply
 

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