Letter Combinations of a Phone Number

easy
Unit 7 · BFS I0/4 to milestone

Old phone keypads map digits to letters: 2: abc, 3: def, 4: ghi, 5: jkl, 6: mno, 7: pqrs, 8: tuv, 9: wxyz. Return all letter combinations a digit string could represent, in lexicographic order. An empty string gives []; digits 0/1 are invalid (ValueError).

Also implement words_for(digits, dictionary): the combinations that appear in dictionary (a set), sorted.

#backtracking#strings2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Letter Combinations of a Phone Number · TechGradify