LeetCode 17. Letter Combinations of a Phone Number 电话号码的字母组合

题目

https://leetcode.com/problems/letter-combinations-of-a-phone-number/description/

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:

Note:

Although the above answer is in lexicographical order, your answer could be in any order you want.

讲解

首先,我们构造一个储存数字和对应字母关系的哈希表。

然后,通过深度优先找到所有的字母组合。

视频教学

Java参考代码

发表评论

电子邮件地址不会被公开。 必填项已用*标注