7 lines C++


  • 0
    class Solution {
    public:
        bool canWin(string s) {
            for(int i = 1; i < s.size(); i++)
                if(s[i - 1] == '+' && s[i] == '+'){
                    s[i - 1] = s[i] = '-';
                    if(!canWin(s)) return true;
                    s[i - 1] = s[i] = '+';
                }
            return false;
        }
    };
    

Log in to reply
 

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