Loading
Loading
A shop wants a memorable vanity number. On an old phone keypad each digit from 2 to 9 stands for a few letters, and the marketing team wants to see every word a short run of digits could spell.
Given digits, return every spelling that picks one letter for each digit, in order. List the spellings in alphabetical order.
digits = "23"a_fix the first letter as a, then try d, e, fb_undo a, fix b, try d, e, f againc_undo b, fix c, last three spellings["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]Sign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
Digit 2 offers a, b, c and digit 3 offers d, e, f: nine pairings, listed alphabetically.
Example 2
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(4ⁿ · n) time · O(n) space
Input. Run your code to watch it work on this input, one line at a time.
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.
A single key yields its own letters.