Letter Combinations of a Phone Number
Given a string containing digits from 2 to 9, return all possible letter combinations that the number could spell on a classic phone keypad. Return the combinations in any order. An empty input string yields an empty list.
Open official problem prompt ↗Enumerate every string obtainable by replacing each digit with one of its keypad letters, one letter per digit.
Old T9 texting: each number key hides several letters, and you want to list every word-shape you could type if you tapped each key once and picked any of its letters.
- Input
- digits = "23"
- Output
- ["ad","ae","af","bd","be","bf","cd","ce","cf"]
- Why
- Digit 2 maps to {a,b,c} and 3 maps to {d,e,f}; every pairing of one letter from each gives 3 x 3 = 9 strings.
0 <= digits.length <= 4digits[i] is a digit in the range ['2', '9']