217. Phone Keypad Combinations
MediumBacktracking
Digits 2–9 map to letters as on a phone keypad (2 = abc, …, 7 = pqrs, 9 = wxyz). Print all letter combinations the digits could represent, in lexicographic order, space-separated.
Input format
A single line of digits 2–9.
Output format
The combinations.
Example 1
Input
23
Output
ad ae af bd be bf cd ce cf
Example 2
Input
2
Output
a b c
Constraints
1 ≤ length ≤ 6
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…