public class Solution {
Map<Character, String> map = new HashMap<Character, String>();
List<String> res = new ArrayList<String>();
public List<String> letterCombinations(String digits) {
if(digits==null||digits.length()==0) return res;
map.put('2', "abc");map.put('3', "def");map.put('4', "ghi");
map.put('5', "jkl");map.put('6', "mno");map.put('7', "pqrs");
map.put('8', "tuv");map.put('9', "wxyz");
String curStr = new String();
dfs(0, digits.length(), curStr, digits);
return res;
}
public void dfs(int cur, int len, String curStr,String digits){
if(cur==len){
res.add(curStr);
return;
}else{
char c = digits.charAt(cur);
String s = map.get(c);
int s_len = s.length();
for(int i=0;i<s_len;++i){
String tmp = new String(curStr+s.charAt(i));
dfs(cur + 1, len, tmp, digits);
}
}
}
}