Please explain; what is the concept behind this question
I didn't understand this video
Approach:
It can be observed that each digit can represent 3 to 4 different alphabets (apart from 0 and 1). So the idea is to form a recursive function.
map the number with its string of probable alphabets, i.e 2 with “abc”, 3 with “def” etc.
Now the recursive function will try all the alphabets, mapped to the current digit in alphabetic order and again call the recursive function for the next digit and will pass on the current output string.
Example:
If the number is 23
Then for 2, the alphabets are a, b, c So 3 recursive function will be called with output string as a, b, c respectively
and for 3 there are 3 alphabets d, e, f So, the output will be ad, ae and af for the recursive function with output string.
Similarly, for b and c, the output will be: bd, be, bf and cd, ce, cf respectively.
Algorithm:
- Map the number with its string of probable alphabets, i.e 2 with “abc”, 3 with “def” etc.
- create a recursive function which takes following parameters, output string, number array, current index and length of number array
- If the current index is equal to the length of number array then print the output string.
- Extract the string at digit[current_index] from the Map, where digit is the input number array.
- Run a loop to traverse the string from start to end
- For every index again call the recursive function with the output string concatenated with the ith character of the string and the current_index + 1.
if have diffculty in any step you can ask
i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.