Update appNew update is available. Click here to update.
sidenav-btnClose
Topic list
Letter Combinations of a Phone Number
MEDIUM
35 mins
10 upvotes
Strings
Topics (Covered in this problem)
Problem solved
Badge
Skill meter
Strings
-
-
Other topics
Problem solved
Badge
Skill meter
Matrices (2D Arrays)
-
-
Linked List
-
-
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
userLevel
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
yellow-spark
0/80
Avg time to solve 35 mins
Success Rate 65 %
Share
10 upvotes

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.

example

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’.
Reset Code
Full screen
Auto
copy-code
Console