Sharing my 0ms C++ solution


  • 0
    T
    class Solution {
    public:
        vector<string> generatePossibleNextMoves(string s) {
            vector<string> result;
            string S = s;
            int n = S.length();
            for(int i=0; i<n-1; i++)
            {
                if(S[i]=='+' && S[i+1]=='+')
                {
                    S[i] = '-';
                    S[i+1] = '-';
                    result.push_back(S);
                    S[i] = '+';
                    S[i+1] = '+';
                }
            }
            
            return result;
        }
    };

Log in to reply
 

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