Close
Topic list
Letter Combinations of a Phone Number
MEDIUM
35 mins
Strings
Topics (Covered in this problem)
Problem solved
Skill meter
Strings
-
-
Other topics
Problem solved
Skill meter
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Letter Combinations of a Phone Number

Contributed by
Vishal Modani
Medium
0/80
Avg time to solve 35 mins
Success Rate 65 %
Share

## Problem Statement

#### Given a string S containing digits from 2 to 9 inclusive. Your task is to find all possible letter combinations that the number could represent.

``````A mapping from Digits to Letters (just like in Nokia 1100) is shown below. Note that 1 does not map to any letter.
``````

Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````1
23
``````
##### Sample Output 1:
``````ad ae af bd be bf cd ce cf
``````
##### Explanation of sample input 1:
``````The letters corresponding to 2 are ‘a’, ‘b’, ‘c’ and corresponding to 3 are ‘d’, ‘e’, ‘f’. All the possible letter combinations for “23” will be "ad","ae","af","bd","be","bf","cd","ce","cf".
``````
##### Sample Input 2:
``````1
2
``````
##### Sample Output 2:
``````a b c
``````
##### Explanation of sample input 2:
``````The letters corresponding to 2 are ‘a’, ‘b’, ‘c’.
``````
Auto
Console