- Letter Combinations of a Phone Number
Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent.
A mapping of digit to letters (just like on the telephone buttons) is given below.

1. Input:Digit string "23"
2. Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
Note:
Although the above answer is in lexicographical order, your answer could be in any order you want.
Solution:
1. public class Solution {
2. public List
3. String[] keyboard = {" ", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
4. 5. List
6. 7. helper(digits, keyboard, 0, "", res);
8. 9. return res;
10. }
11. 12. private void helper(String digits, String[] keyboard, int index, String sol, List
13. if (sol.length() == digits.length()) {
14. res.add(sol);
15. return;
16. }
17. 18. int idx = (int)(digits.charAt(index) - '0');
19. String key = keyboard[idx];
20. 21. for (int i = 0; i < key.length(); i++) {
22. helper(digits, keyboard, index + 1, sol + key.charAt(i), res);
23. }
24. }
25. }
