代码随想录
class Solution {String[] numString = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};List<String> res = new ArrayList<>();public List<String> letterCombinations(String digits) {if(digits == null || digits.length() == 0 ) {return res;}backtracking(digits,0);return res;}StringBuilder temp = new StringBuilder();public void backtracking(String digits,int num){if(temp.length() == digits.length()){res.add(temp.toString());return;}String str = numString[digits.charAt(num)- '0'];for(int i = 0 ; i < str.length() ; i ++){temp.append(str.charAt(i));backtracking(digits,num+1);temp.deleteCharAt(temp.length()-1);}}}