Bootcamps
Masterclasses
Menu
Courses
Account
Login / Sign Up

Letter Combinations of Phone Number

Medium Acceptance 60% Points 30

The Letter Combinations of Phone Number problem requires generating all possible letter combinations that a given digit string could represent based on the mapping of digits to letters on a telephone keypad. Each digit from 2 to 9 maps to a set of letters.

The task is to return all possible letter combinations that can be formed by choosing one letter for each digit in the same order.

Digit to letter mapping follows the standard phone keypad:

2 ? "abc"

3 ? "def"

4 ? "ghi"

5 ? "jkl"

6 ? "mno"

7 ? "pqrs"

8 ? "tuv"

9 ? "wxyz"

Examples
Example 1

Example 1

Input: digits = "23"

Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"]

Explanation: Digit '2' maps to "abc" and digit '3' maps to "def". All possible combinations are formed by pairing each letter of "abc" with each letter of "def".

Example 2

Example 2

Input: digits = ""

Output: []

Explanation: Since no digits are provided, no letter combinations can be formed.

Example 3

Example 3

Input: digits = "7"

Output: ["p","q","r","s"]

Explanation: Digit '7' maps to "pqrs", so each letter itself forms a valid combination.

Constraints
  • 0 = digits.length = 4
  • digits[i] is a digit from '2' to '9'
Topics
Recursion
Companies
Amazon Microsoft
Added 19 Jul 2026 60% acceptance
Ln 1, Col 1Sign in to save your code
23
ad ae af bd be bf cd ce cf