# 293 Flip Game

You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip twoconsecutive "++" into "--". The game ends when a person can no longer make a move and therefore the other person will be 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 \[].

```cpp
  #include <iostream>
  #include <string>
  #include <vector>
  using namespace std;

  vector<string> nextPossibleMoves(string s)
  {
      int memory = 0;
      string goBack = s;
      vector<string> moves;
      while (memory < s.size() - 1)
      {
          for (int i = memory; i < s.size(); i++)
          {
              if (i == s.size() - 1) break;
              if (s.at(i) == '+' && s.at(i + 1) == '+')
              {
                  // replace(position, length, string)
                  s = s.replace(i, 2, "--");
                  moves.push_back(s);
                  s = goBack;
                  memory = i + 1;
                  break;
              }
              else memory += 2;
          }
      }
      return moves;

  }

  int main()
  {
      vector<string> moves = nextPossibleMoves("--++--++-----------++++++++++++---++---+++++++---++-+");

      for (auto i : moves) cout << i << endl;
  }
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://maksimdan.gitbook.io/interview-practice-problems/leetcode_sessions/flip_game_293.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
