Loading...
Loading...
Loading...
A messaging app shows letters under the digit keys: 2 abc, 3 def, 4 ghi, 5 jkl, 6 mno, 7 pqrs, 8 tuv, 9 wxyz. Given the digits a user pressed, print every letter combination they could mean, one per line. Earlier letters of the first key come first.
Example
Input
23
Output
ad ae af bd be bf cd ce cf
Nine words.
Try the problem first. Open one hint at a time.
Handle one digit per level of the recursion. The choices at each level are the letters on that key.
When every digit is used, print the path as one word.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor