Thursday, August 20, 2015

MJ [18] Who wins -- LeetCode [292] Nim Game

Question:
Two players are playing a game by taking coins from a stack of n coins in turn. Each player can only take 1, 3 or 4 coins at a time. Whoever takes the last coin wins the game and the other player loses. Determine whether the first player can win the game. Note that if n=0, the first player loses because he/she cannot take the last coin.

Ref
[1] http://www.mitbbs.com/article_t/JobHunting/33010083.html
[2] https://www.topcoder.com/community/data-science/data-science-tutorials/algorithm-games/
[3] https://leetcode.com/problems/nim-game/
[4] https://leetcode.com/discuss/63684/simple-java-solution-with-explanation

No comments:

Post a Comment