clueless coding // TODO: be smarter

LeetCode Flip Game: CPP Solution



TL;DR Code Solution


vector<string> generatePossibleNextMoves(string s) {

    vector<string> result;

    for (int i = 0; i < (int)s.length() - 1; i++) {
        if (s[i] == '+' && s[i + 1] == '+') {
            s[i] = '-'; s[i + 1] = '-';
            result.push_back(s);
            s[i] = '+'; s[i + 1] = '+';
        }
    }

    return result;        

}