Friday, August 21, 2015

MJ [22] Who wins V

Question:
Two player change a string s in turn. s only has two types of characters '+' or '-'. When his/her turn, the player chooses two consecutive '-'(ie., "--") and replace them by "++". A player wins when he/she cannot make a move on his/her turn. Given string s, determine whether the first player can win.

Eg.1, if s="++", the first player wins because he/she cannot move at the first step
Eg.2, if s="--", the first player must replace "--" with "++" at the first step, thus the second player wins
Eg.3, if s="----", the first player wins by replace the first/last two '-' (so s becomes "++--"/"--++") at the first step.
Ref
[1] http://www.mitbbs.com/article_t/JobHunting/33010083.html
[2] http://likemyblogger.blogspot.com/2015/10/leetcode-294-flip-game-ii.html

No comments:

Post a Comment