Letter Combinations of a Phone Number
Problem Statement
You are given a string of digits from 2 to 9. Each digit is a button on an old phone keypad, and each button stands for some letters:
2 → abc, 3 → def, 4 → ghi, 5 → jkl, 6 → mno, 7 → pqrs, 8 → tuv, 9 → wxyz
Make words by picking one letter for each digit, in order. Return every word you can make.
You may return the words in any order.
A string digits of characters 2 to 9. The problem guarantees at least one digit. If the string is empty, return [], not a list holding one empty word.
A list of every word. Each word has one letter per digit.
Digit 2 gives a, b or c. Digit 3 gives d, e or f. Every pair (one letter from each) makes a word, so there are 3 × 3 = 9 words.
Digit 2 has three letters, so there are three one-letter words.
- • 1 ≤ digits.length ≤ 4
- • digits[i] is a digit from 2 to 9
Pattern Recognition Clues
Recognising these key signals in the problem description immediately identifies the pattern:
Approach Complexity Ladder
Start from [""]; for each digit, extend every partial word by its letters
Recurse on the digit position; push a letter, recurse, then pop it
Keep a list of partial words, starting with one empty word. For each digit, make a new list: take every partial word and add each letter of that digit to it. After the last digit, the list holds every full word.
Recognition rule for this sub-pattern:
Unlock Complete Visual Walkthrough & Optimal C++
The interactive animated dry-run player, optimized C++ implementation, state invariant derivations, and edge-case breakdown for this question are part of Brute2Best Pro. The anchor question of every sub-pattern is completely free.
First anchor question per pattern, Part 1 LLD & Module 1 C++ basics are 100% Free forever.
How this concept connects to System Design & C++ Systems
Top engineering interviews test whether you understand how algorithms like Backtracking translate into production architectures and low-level memory mechanics.
Foundations: Object-Oriented Principles in C++23
Class invariants, pure virtual interfaces, and RAII smart pointers.
Food Delivery System (Zomato Architecture)
Real-world machine coding application of algorithms and design patterns.
Pointers vs References Deep Dive
Pointer arithmetic and memory layout under the hood.
Virtual Method Table (vtable) & Memory Layout
Polymorphism, vptr overhead, and multiple inheritance in memory.