题目描述:
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.
note:
Although the answer is in lexicographical order, your answer could be in any order you want.
样例:
1 | Input: "23" |
题意:
给定只包含 2 - 9 之间的一个字符串代表一个数字,返回这个数字所有的组合
思路:
就是根据 2 - 9 所对应的字符进行一个标记,然后直接 dfs 遍历所有的可能的结果。
1 | class Solution { |
Runtime:8ms Memory:10.3MB