17 Letter Combinations of a Phone Number
1. Question
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.
2. Implementation
(1) Backtracking
3. Time & Space Complexity
时间复杂度O(L^n), L为digits的长度, n为一个数字对应的最长letters的长度, 空间复杂度O(L^n)
Last updated
Was this helpful?