My code:
public class Solution {
public List<String> generatePossibleNextMoves(String s) {
List<String> ret = new ArrayList<String>();
if (s == null || s.length() == 0) {
return ret;
}
char[] arr = s.toCharArray();
for (int i = 0; i < arr.length - 1; i++) {
if (arr[i] == arr[i + 1] && arr[i] == '+') {
arr[i] = '-';
arr[i + 1] = arr[i];
ret.add(String.valueOf(arr));
arr[i] = '+';
arr[i + 1] = '+';
}
}
return ret;
}
}
简单题,没什么好说的。
Anyway, Good luck, Richardo! — 09/19/2016