# 电话号码的字母组合

<p>给定一个仅包含数字 <code>2-9</code> 的字符串，返回所有它能表示的字母组合。答案可以按 <strong>任意顺序</strong> 返回。</p><p>给出数字到字母的映射如下（与电话按键相同）。注意 1 不对应任何字母。</p><p><img src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0017.Letter%20Combinations%20of%20a%20Phone%20Number/images/17_telephone_keypad.png" style="width: 200px;" /></p><p> </p><p><strong>示例 1：</strong></p><pre><strong>输入：</strong>digits = "23"<strong><br />输出：</strong>["ad","ae","af","bd","be","bf","cd","ce","cf"]</pre><p><strong>示例 2：</strong></p><pre><strong>输入：</strong>digits = ""<strong><br />输出：</strong>[]</pre><p><strong>示例 3：</strong></p><pre><strong>输入：</strong>digits = "2"<strong><br />输出：</strong>["a","b","c"]</pre><p> </p><p><strong>提示：</strong></p><ul>	<li><code>0 <= digits.length <= 4</code></li>	<li><code>digits[i]</code> 是范围 <code>['2', '9']</code> 的一个数字。</li></ul>

## template

```java
class Solution {
	public List<String> letterCombinations(String digits) {
		Character[][] letters = { {}, {}, { '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' }, };
		List<List<Character>> combinations = new ArrayList<>();
		for (int i = 0; i < digits.length(); i++) {
			Character d = digits.charAt(i);
			int index = Character.getNumericValue(d);
			Character[] letter = letters[index];
			System.out.println(d);
			if (i == 0) {
				for (int j = 0; j < letter.length; j++) {
					List<Character> c = new ArrayList<>();
					c.add(letter[j]);
					combinations.add(c);
				}
			} else {
				List<List<Character>> added = new ArrayList<>();
				for (int j = 0; j < combinations.size(); j++) {
					List<Character> c = combinations.get(j);
					List<Character> origin_c = new ArrayList<>(c);
					for (int k = 0; k < letter.length; k++) {
						Character l = letter[k];
						if (k == 0) {
							c.add(l);
						} else {
							List<Character> new_c = new ArrayList<>(origin_c);
							new_c.add(l);
							added.add(new_c);
						}
					}
				}
				combinations.addAll(added);
			}
		}
		List<String> output = new ArrayList<>();
		for (int i = 0; i < combinations.size(); i++) {
			List<Character> c = combinations.get(i);
			StringBuilder sb = new StringBuilder();
			for (Character l : c) {
				sb.append(l);
			}
			output.add(sb.toString());
		}
		return output;
	}
}
```

## 答案

```java

```

## 选项

### A

```java

```

### B

```java

```

### C

```java

```