Skip to content
Veltoryx Technologies
ProProblem 78● MediumLeetCode #17 ↗3 min readUpdated 30 October 2026

Letter Combinations of a Phone Number

Map digits from a telephone keypad to all possible word combinations using recursive multi-way backtracking.

01The problem

Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order.

A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.

  • 2: "abc", 3: "def", 4: "ghi", 5: "jkl"
  • 6: "mno", 7: "pqrs", 8: "tuv", 9: "wxyz"
InputOutputWhy
digits = "23"["ad","ae","af","bd","be","bf","cd","ce","cf"]Cartesian product of {a, b, c} and {d, e, f}
digits = ""[]Empty string yields empty list
digits = "2"["a","b","c"]Three single-letter combinations

Constraints: 0 <= digits.length <= 4, digits[i] is a digit in the range ['2', '9'].

Loading the rest of the lesson…