Letter Combinations of a Phone Number
Given a string digits containing digits from 2 to 9, return all possible letter combinations that the number could represent.
The mapping of digits to letters is the same as on a telephone keypad:
2 → abc
3 → def
4 → ghi
5 → jkl
6 → mno
7 → pqrs
8 → tuv
9 → wxyz
Return the combinations in any order.
If digits is empty, return an empty list.
Example 1
Input
digits = "23"
Output
ad ae af bd be bf cd ce cf
Explanation
Digit 2 represents a, b, c.
Digit 3 represents d, e, f.
Therefore, all possible combinations are:
ad ae af
bd be bf
cd ce cf
Example 2
Input
digits = "7"
Output
p q r s
Explanation
Digit 7 represents four letters:
p q r s
So there are four possible combinations.
Constraints
Hints:
Hint 1
Create a mapping from every digit to its corresponding letters.
Hint 2
Use backtracking. For each digit, try every letter mapped to that digit and recursively process the next digit.
Author & Technical Reviewer
Technically reviewed by: ExamAdda Technical Review Team
Technical Reviewers, ExamAdda
Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.
Published
Aug 20, 2026
Last updated
Aug 20, 2026
Content Verification Methodology
Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.
Expected Output