17. Letter Combinations of a Phone Number

Problem

Given a digit string, 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: Although the above answer is in lexicographical order, your answer could be in any order you want.

Related Topics:

String Backtracking

Analysis

方法一:通过函数递归调用,进行字符串拼接。

方法二:利用队列的先进先出,进行字符串拼接。

Code

递归

队列

Last updated