C++ concise AC

  • 1
    bool canWin(string s) {
            int len = s.size();
            for(int i=0;i<(len-1);i++){
                if(s[i]=='+' && s[i+1]=='+' ){
                    s[i]= s[i+1] = '-';
                    if( !canWin(s) )return true;//after flip, if B can win
                    s[i]= s[i+1] = '+';
            return false;//either no available flip or no guarantee win move

Log in to reply

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