Letter Combinations of a Phone Number
Return every letter string formed by choosing one telephone-keypad letter per digit in order. Digits 2..9 map to abc, def, ghi, jkl, mno, pqrs, tuv, wxyz.
Example 1
digits = "24"["ag","ah","ai","bg","bh","bi","cg","ch","ci"]Explanation
Choose from abc for 2 and ghi for 4, producing nine ordered strings.
Example 2
digits = ""[]Explanation
Empty digits produce no letter strings under this contract.
Example 3
digits = "7"["p","q","r","s"]Explanation
Digit 7 has four letters: p,q,r,s.
Constraints
- 0 <= number of digits <= 4
- Digits are 2..9
- Empty input returns an empty result
Function contract
letterCombinationsArguments: jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 34 cases, on your device.
"24"