递归入门题
执行用时 :
0 ms, 在所有 java 提交中击败了 100.00% 的用户
内存消耗 :36.1 MB, 在所有 java 提交中击败了 73.28% 的用户
class Solution {
    List<String> list = new ArrayList<String>();
    char[][] numbers = new char[][]{{},{},{'a','b','c'},{'d','e','f'},{'g','h','i'},{'j','k','l'},{'m','n','o'},
            {'p','q','r','s'},{'t','u','v'},{'w','x','y','z'}};
    void dfs(int index,int length,String str,String digits) {
        if(index == length) {
            list.add(str);
            return;
        }else {
            int num = digits.charAt(index)-'0';
            for(int i = 0;i<numbers[num].length;i++) {
                dfs(index + 1,length,str + numbers[num][i],digits);
            }
        }
    }
    public List<String> letterCombinations(String digits) {
        if(!"".equals(digits)) {
            dfs(0,digits.length(),"",digits);
        }
        return list;
    }
}