1 2 3 4 5 6 7 8 9 10 11 12 13 | public class Solution { public List<String> generatePossibleNextMoves(String s) { List<String> result = new ArrayList<String>(); if (s == null) return result; for (int i = 0; i < s.length()-1; i++){ if (s.charAt(i) == '+' && s.charAt(i+1) == '+'){ result.add(s.substring(0, i)+"--"+ ((s.length()-1) >= i+2?s.substring(i+2, s.length()):"")); } } return result; } } |
No comments:
Post a Comment