Letter Combinations of a Phone Number
Medium
LC #17
cartesian productstringsNot attempted yet
On an old phone keypad each digit from 2 to 9 stands for some letters:
2: abc 3: def 4: ghi 5: jkl
6: mno 7: pqrs 8: tuv 9: wxyz
Given a string digits, return every string of letters it
could represent (one letter per digit, in order). Return
them in any order. An empty digits gives an empty list.
Example 1
Input: digits = "23"
Output: ["ad","ae","af","bd","be",
"bf","cd","ce","cf"]
Example 2
Input: digits = ""
Output: []
Example 3
Input: digits = "2"
Output: ["a","b","c"]
Constraints
- 0 ≤ len(digits) ≤ 4
- Each character of
digitsis in '2'–'9'.