# 电话号码的字母组合

**电话号码的字母组合**

给定一个仅包含数字 2-9 的字符串，返回所有它能表示的字母组合。给出数字到字母的映射如下（与电话按键相同）。注意 1 不对应任何字母。

```javascript
var letterCombinations = function(digits) {
    if(!digits) return [];
    let map = {
        '2': 'abc','3':'def','4':'ghi','5':'jkl','6':'mno','7':'pqrs','8':'tuv','9':'wxyz'
    };
    let res = [];
    function dfs(index,path) {
        if(index === digits.length) {
            res.push(path);
            return;
        }
        for (let i = 0;i < map[digits[index]].length;i++) {
            path += map[digits[index]][i];
            dfs(index+1,path.slice());
            path = path.slice(0, path.length-1);
        }
    }
    dfs(0,'');
    return res;
};

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://voyz.gitbook.io/voyz-algorithm/zi-fu-chuan/dian-hua-hao-ma-de-zi-mu-zu-he.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
