题目:
    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 two consecutive “++” 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 [].

    翻译文:

    你正在和你的朋友玩下面的翻转游戏:给定一个字符串,它只包含这两个字符:+和-,你和你的朋友轮流把两个连续的“++”翻转成“——”。游戏结束时,一个人不能再采取行动,因此另一个人将是赢家。
    写一个函数来计算一个有效移动后字符串的所有可能状态。

    ``

    1. public class Solution {
    2. public List<String> generatePossibleNextMoves(String s) {
    3. // 哈哈哈, 没看懂
    4. List<Character> list = new ArrayList<>();
    5. Char []str = s.toCharArray();
    6. for(int i = 1; i < s.length(); i++){
    7. if(str[i] == '+' && str[i - 1] == '+'){
    8. str[i] = '-';
    9. str[i - 1] = '-';
    10. list.add(String.valueOF(str));
    11. str[i] = '+';
    12. str[i - 1] = '+';
    13. }
    14. }
    15. return list;
    16. }
    17. }

    ``