Letter Combinations of a Phone Number
Given a string digits containing digits from 2 to 9 inclusive, return all possible letter combinations that the number could represent.
Use the same digit-to-letter mapping as on a telephone keypad:
2:abc3:def4:ghi5:jkl6:mno7:pqrs8:tuv9:wxyz
Return the combinations in any order.
Example 1
Input
digits = "23"Output
["ad","ae","af","bd","be","bf","cd","ce","cf"]Digit 2 maps to abc and digit 3 maps to def, so every pair formed by one letter from each group is included.
Example 2
Input
digits = "2"Output
["a","b","c"]There are no digits to map, so there are no possible letter combinations.
Constraints
- 1 <= digits.length <= 4
- digits[i] is a digit in the range ['2', '9']