mediumBacktrackingFacebookAmazonUber
Dialpad Dictionary Dialer
A T9 keypad emits every possible letter combination for a dialed digit sequence (e.g. '23' -> ad, ae, …, cf).
Given a string of digits 2-9, return all possible letter combinations the number could represent (using the standard phone keypad mapping).
Choose approach
2
03
1i
SetCombinations (0)
empty
1/21
Narrationstep 1 of 21
Pick 'a' from digit 2.
Variables
cur=a
out=0
How to think about it
- Static digit→letters map.
- DFS tree width ≤ 4, depth = number of digits.
- Empty input -> empty output (not a single empty string).
Edge cases to catch in interview
- Digits with no letters (0, 1) -> interview constraint typically excludes.
- Empty string input -> return empty list, not [''].
Examples
Example 1
["ad","ae","af","bd","be","bf","cd","ce","cf"]{"digits":"23","values":["2","3"]}
Try your own input
SpacePlay / pause
← / →Previous / next step
RReset to start
. or >Cycle speed