Letter Combinations of a Phone Number

Medium · Backtracking · about 15 minutes

Asked at Amazon, Meta, Uber, Google.

Given a string of digits 2–9, return every letter combination the number could represent on a phone keypad (2 → "abc", 3 → "def", …, 7 → "pqrs", 9 → "wxyz"), in any order. An empty input gives an empty list.

Related guides