Question: Write a function that takes in a string containing digits and returns all possible letter combinations that the digits could represent. The mapping of digits
Write a function that takes in a string containing digits and returns all possible letter combinations that the digits could represent. The mapping of digits to letters is as follows: 2 maps to "abc", 3 maps to "def", 4 maps to "ghi", 5 maps to "jkl", 6 maps to "mno", 7 maps to "pqrs", 8 maps to "tuv", and 9 maps to "wxyz". The output should be sorted in lexicographic order.
For example, if the input string is "23", the function should return ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
Step by Step Solution
3.54 Rating (147 Votes )
There are 3 Steps involved in it
The detailed answer for the above question is provided below def lettercombinationsdigits if not dig... View full answer
Get step-by-step solutions from verified subject matter experts
