You is playing the following Flip Game with your Friend:given a string this contains only these both characters: an + D - , you and your friend take turns to flip the consecutive "++" into "--" . The game ends when a person can no longer make a move and therefore the other person would be the the winner.
Write a function to compute all possible states of the string after one valid move.
For example, given s = "++++" , after one move, it may become one of the following states:
[ "--++", "+--+", "++--"]
If There is no valid move, return an empty list [] .
1 classSolution {2 Public:3vector<string> generatepossiblenextmoves (strings) {4vector<string>Res;5 for(inti =0, n = s.size ()-1; I < n; i++)6 if(S[i] = ='+'&& S[i +1] =='+') {7 stringtemp =s;8Temp[i] = temp[i +1] ='-';9 Res.push_back (temp);Ten } One returnRes; A } -};
Flip Game--Leetcode