Flip Game
给一个string s, 问翻转其中两个连续的+号, 能有几种翻法?
public List<String> generatePossibleNextMoves(String s) { List<String> res = new ArrayList<String>(); for (int i = 0; i < s.length() - 1; i++) { if (s.charAt(i) == '+' && s.charAt(i + 1) == '+') { res.add(s.substring(0, i) + "--" + s.substring(i + 2, s.length())); } } return res; }
Leave A Comment