public List<String> letterCasePermutation(String S) {
List<String> res = new LinkedList<>();
dfs("", S, res, 0);
return res;
}
public void dfs(String pre, String S, List<String> res, int index) {
System.out.println(pre+"-----------");
// 判断结束的条件,因为没有for循环所以只能这么判断
if (index == S.length())
res.add(pre);
else {
//System.out.println(pre + "//////////////" + index);
char ch = S.charAt(index);
// 指定这是一个字母啊,就是数字,
if (!Character.isLetter(ch))
dfs(pre + ch, S, res, index + 1);
else {
// System.out.println("xiaoxie");
// 将字符参数转化为小写的
ch = Character.toLowerCase(ch);
dfs(pre + ch, S, res, index + 1);
// System.out.println("===========" + index);
// 将字符参数转化为大写的
ch = Character.toUpperCase(ch);
dfs(pre + ch, S, res, index + 1);
}
}
}