Given a string of digits between 2 and 9, imagine the classic telephone keypad where each of those digits maps to a small group of letters. Produce every possible string of letters that could be typed by pressing the given digits in order, choosing one letter per digit.
Return all such combinations in any order. If the input string is empty, there are no letters to choose and the answer is an empty list.
Example 1
Input: digits = "23"
Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]
Digit two offers a, b, c and digit three offers d, e, f, so every pairing is produced.
Example 2
Input: digits = ""
Output: []
No digits means there is nothing to combine.
Constraints
0 <= digits.length <= 4Each character in digits is a digit from 2 through 9No two returned combinations are identicalSee the step-by-step animation, the intuition, and clean code in every language — free, no credit card.
FDE Coach is a cohort-based program in frontend, backend, AWS, and AI where you build real products and get referred to 200+ hiring partners. The free live workshop is the fastest way to see how we teach.
750+ engineers trained · frontend, backend, AWS & AI