diff --git a/Array/Easy/Letter Combinations_of_a_Phone_Number.java b/Array/Easy/Letter Combinations_of_a_Phone_Number.java new file mode 100644 index 0000000..cddcbd7 --- /dev/null +++ b/Array/Easy/Letter Combinations_of_a_Phone_Number.java @@ -0,0 +1,34 @@ +class Solution { + public List letterHelper(String digit,HashMap map){ + if(digit.equals("")) return new ArrayList (0); + if(digit.length() == 1){ + List list = new ArrayList<>(3); + String s = map.get(digit.charAt(0)); + for(int i = 0;i list = letterHelper(digit.substring(1,digit.length()),map); + List result = new ArrayList<>(); + String s = map.get(digit.charAt(0)); + for(int i = 0;i letterCombinations(String digits) { + HashMap map = new HashMap<>(8); + 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"); + return letterHelper(digits,map); + } +} \ No newline at end of file