- 时间:2019-06-18
- 题目链接:https://leetcode.com/problems/letter-combinations-of-a-phone-number/
- tag:
backtrack
Given a string containing digits from 2-9 inclusive, 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. Note that 1 does not map to any letters.
Example:
Input: "23"
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.
求解电话号码能够组成的所有可能性。由于要列举所有的,因此很容易想到的是全排列,而不是 DFS. 如果大家之前看过我仓库的话,应该知道这种题目有一个通用的解题框架和模板。 今天我们就来巩固下这个解题思路。 题目简单直接我就不说了,如果没有明白的可以移步到我的仓库中继续看。 比如 https://github.com/azl397985856/leetcode/blob/master/problems/39.combination-sum.md 就用到了这种方法(回溯法)
暂无