Possible Words from a Phone Number: Problem Statement
Given a string S
composed of digits ranging from 2 to 9, determine all possible strings that can be created by mapping these digits to their corresponding letters on a T9 keypad. The resulting strings should be printed in lexicographically sorted order.
Example:
Input:
S = "34"
Output:
dg dh di eg eh ei fg fh fi
Explanation:
Mapping the digits 3 and 4 produces strings using letters {"d", "e", "f"} for 3, and {"g", "h", "i"} for 4, resulting in a total combination of strings.
Constraints:
1 <= T <= 10
1 <= |S| <= 7
- |S| denotes the length of string S
- Time limit: 1 sec
Note:
You do not need to print anything; it has already been taken care of. Just implement the given function.
AnswerBot
1mo
Given a phone number, generate all possible words by mapping digits to letters on a T9 keypad.
Create a mapping of digits to letters on a T9 keypad
Use recursion to generate all possible combinations of...read more
Help your peers!
Add answer anonymously...
Top Tata 1mg Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app