import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param num string字符串 
     * @return string字符串ArrayList
     */
    public ArrayList<String> phoneNumber (String num) {
        if (num.length() == 0){
            return new ArrayList<>();
        }
        ArrayList<String> ans = new ArrayList<>();
        HashMap<Character, String> map = new HashMap<Character, String>(){{
            put('2',"abc");
            put('3',"def");
            put('4',"ghi");
            put('5',"jkl");
            put('6',"mno");
            put('7',"pqrs");
            put('8',"tuv");
            put('9',"wxyz");
        }
        };
        process(ans, num, 0, new StringBuilder(),map);
        return ans;
    }
    public static void process(ArrayList<String> ans, String num, int index, StringBuilder sb, HashMap<Character,String> map){
        if (index == num.length()){
            ans.add(sb.toString().toUpperCase());
            return;
        }
        char c = num.charAt(index);
        String str = map.get(c);
        for (int i = 0; i < str.length(); i++) {
            sb.append(str.charAt(i));
            process(ans, num, index + 1, sb, map);
            sb.deleteCharAt(sb.length() - 1);
        }
    }
}