C++ 3ms solution


  • 0
    vector<string> generatePossibleNextMoves(string s) {
            vector<string>res;
            if(s.size()<2) return res;
            string::iterator it=s.begin();
            while(it!=s.end()-1){
                if(*it=='+'&&*(it+1)=='+'){
                    *it='-',*(it+1)='-';
                    res.push_back(s);
                    *it='+',*(it+1)='+';
                }
                it++;
            }
            return res;
        }
    

Log in to reply
 

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