# Middle-题目72：17. 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.

Input:Digit string “23”
Output: [“ad”, “ae”, “af”, “bd”, “be”, “bf”, “cd”, “ce”, “cf”].

public class Solution {
private String[][] letters = new String[][] {
{" "},
{},
{"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"}
};
public List<String> letterCombinations(String digits) {
List<String> list = new ArrayList<String>();
if(digits.length() > 0)
backtrack(list, digits, new String(), 0);
return list;
}
private void backtrack(List<String> list, String digits, String currentLetter, int index) {
if(index == digits.length()) {
return;
}
else {
int num = digits.charAt(index) -'0';
for(int i = 0; i < letters[num].length; i++) {
currentLetter+=letters[num][i];
backtrack(list, digits, currentLetter, index+1);
currentLetter = currentLetter.substring(0,currentLetter.length()-1);
}
}
}
}

1ms，beats 46.02%，众数1ms,53.98%

#### LeetCode --- 17. Letter Combinations of a Phone Number

2015-01-30 21:30:34

#### (Java）LeetCode-17. Letter Combinations of a Phone Number

2016-05-29 22:35:46

#### LeetCode 17 Letter Combinations of a Phone Number(C,C++,Java,Python)

2015-05-10 13:39:32

#### 17. Letter Combinations of a Phone Number-python

2017-07-02 10:03:17

#### [leetcode] 17. Letter Combinations of a Phone Number ,python实现【medium】

2016-06-14 22:25:54

#### 【LeetCode】LeetCode——第17题：Letter Combinations of a Phone Number

2016-04-29 21:40:59

#### LeetCode----17. Letter Combinations of a Phone Number（遍历树+多重循环）

2016-09-19 16:49:35

#### LeetCodet题解--17. Letter Combinations of a Phone Number（所有数字键盘组合所对应的所有字符集合）

2016-04-07 16:53:23

#### [C++]LeetCode: 87 Letter Combinations of a Phone Number

2015-01-11 13:29:49

#### LeetCode 17 - Letter Combinations of a Phone Number

2015-05-20 11:25:19