AlgoForge
LearnPracticeMockPricing
AlgoForge

Master DSA patterns and ace your next technical interview.

Learn

  • Curriculum
  • Problems
  • Daily Challenge
  • Mock Interview

Account

  • Dashboard
  • Pricing
  • Sign In
  • Get Started

Company

  • Privacy Policy
  • Terms of Service

© 2026 AlgoForge. All rights reserved.

Built for engineers who ship.

mediumBacktracking

Letter Combinations of a Phone Number

## 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 telephone buttons) is given below:
- 2 → abc, 3 → def, 4 → ghi, 5 → jkl
- 6 → mno, 7 → pqrs, 8 → tuv, 9 → wxyz

Examples

Input
digits = "23"
Output
["ad","ae","af","bd","be","bf","cd","ce","cf"]
2→abc, 3→def — all 9 combinations.
Input
digits = ""
Output
[]
Empty input → empty output.
Input
digits = "2"
Output
["a","b","c"]
Single digit.

Constraints

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