I cant able to get the logic

what should i do so i can think and make code logic myself

Hey @anubhavb11
Let’s understand the question first.
Consider two examples:

  1. Let’s Start with 1023;

[1,2,3] =ABC
[1,23]=AW
[10,2,3]=JBC
[10,23]=JW
2. Now, coming to the next example 1432

[1,4,3,2]=ADCB
[14,3,2]=NCB
Approach :

  • Bigger Problem : To Print all of the possible mapped String of given number.
  • Smaller Problem : Assume the recursion works and will give you ans for just after the first digit.
  • Self Work : In order to make you smaller prblm your problem all you need to work for the 0th index element. Because it could be the part included in the answer or not. So first number could be mapped as it is or can be mapped by including just the next digit with. For e.g…, 123 either first digit will be mapped as β€˜1’ or as β€˜12’ but not for β€˜123’

Note : Do handle that the number should be smaller than 26 as for two digit number could be like 321 so your recursion will take either 3 or 32 but 32 is not valid.


i tried but it is not working fine

Hey,If your doubt is resolved then please mark it resolved :slight_smile:
Otherwise let me know the issue .

actually no it is not cleared yet

code- https://ide.codingblocks.com/s/320097?_ga=2.219824478.638373536.1598118928-1159111060.1598118928

Hey your code is not even close to actual solution
We will have 2 arguments in recursion input string and output string (no need to take an array)’
Say input string is 123 then Initial we have
( β€œ123” ,"" )
now we can take 1 char if its not 0 so we will take 1 convert to A & make recursive call (β€œ23”,β€œA”)
Also we can take 2 char only if atleast two char left in string & they are >=10 & <=26 so current 2 digit num is 12 so we take it and convert to corresponding char and make recursive call (β€œ3” ,β€œL”)

from (β€œ23”,β€œA”) we can go to (β€œ3”,β€œAB”) & ("",β€œAW”) in second case since input is empty we can print output string
and rest of the recursion call will follow

Hey , If your doubt is resolved then please mark it resolved :slight_smile:
Otherwise let me know the issue.

Hey @anubhavb11
If this doubt it resolved then please marki it so or let me know the issue.