Letter Combinations of a Phone Number Problem Statement
You are 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, based on the mapping from digits to letters, similar to the traditional mobile phone keypads.
Input:
The first line of input includes an integer 'T', which represents the number of test cases.
Each of the next 'T' lines contains a single string 'S', representing the sequence of digits.
Output:
For each test case, output a list of all possible letter combinations.
Print the results for each test case on a new line.
Example:
Input:
T = 1
S = "23"
Output:
["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]
Explanation:
Digit '2' maps to letters "abc" and digit '3' maps to "def". Thus, all combinations of these letter pairs are shown.
Constraints:
- 1 <= T <= 10
- 1 <= |S| <= 10
- 2 <= S[i] <= 9
Where |S| is the length of the string 'S', and 'S[i]' denotes the element of the string S.
Note: You don’t have to print anything; it is handled internally. Implement the function accordingly, and the output can be returned in any order.

Given a string of digits, find all possible letter combinations based on phone keypad mapping.
Use a recursive approach to generate all possible combinations of letters for each digit in the input stri...read more
Nagarro Software Developer interview questions & answers
Popular interview questions of Software Developer


Reviews
Interviews
Salaries
Users

