Interview question: Letter Combinations of a Phone Number
Problem Description
Given a string digits
containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. The mapping of digits to letters is as follows:
Constraints:
0 <= digits.length <= 4
digits[i]
is a digit from'2'
to'9'
.
Example 1
Input: digits = "23"
Result: ["ad","ae","af","bd","be","bf","cd","ce","cf"]
Example 2
Input: digits = ""
Result: []
Example 3
Input: digits = "2"
Result: ["a","b","c"]