CodeSpeek

Letter Combinations of a Phone Number

Medium · Backtracking

You are given a string of digits between 2 and 9, like an old phone keypad input. Each digit maps to a set of letters, the same way it did on classic phone keypads (2 is abc, 3 is def, and so on, with 7 mapping to qprs and 8 to tuv). Return every possible letter combination you could make by choosing one letter for each digit in order. If the input string is empty, return no combinations at all.

Practise it by voice

Describe the solution out loud and the interviewer writes exactly what you say, asks when you are vague, and runs the tests in your browser.

Practise Letter Combinations of a Phone Number

This statement is written for CodeSpeek. The problem is part of the NeetCode 150 list; Watch NeetCode's explanation of Letter Combinations of a Phone Number. Reference solutions from the NeetCode repository (MIT) are used to verify our tests.