Short C++ code


  • 0
    G
        vector<string> generatePossibleNextMoves(string s) {
            vector<string> ans;
            for (int i = 1; i < s.size(); i++) {
                if (s[i - 1] == '+' && s[i] == '+') {
                    s[i - 1] = s[i] = '-';
                    ans.push_back(s);
                    s[i - 1] = s[i] = '+';
                }
            }
            return ans;
        }
    

Log in to reply
 

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