can you please dry run this for input 123 and for AW
Mapped string problem
Hi Ajit
Whenever u need to use a string
Use char array instead of string object
When u backtrack u need to use erase function in string but in char aaray index auto magically manage it
hey, my question is not about this… i am not able tto understand the code above for output AW
1 is for A and 23 is for W
when u get in 2nd recursive call
u have ABC in the output string and when in 2nd recursive call u get 3 first and then 2 so u mke the number 23 check wheather it is <=26 or not and yes it is then u make a rec call now u r taking two element and thus u get output AW
how we get A in second recursive call When ABC is printed
In the recursive stack when abc is formed and u printed it then u return
In that case u have ab in output string and ur I index pointed to 3 in 123
Now u cannot take 2 element at a time so second recursive call is not made and u return
Now when u return u have a in output string and i is pointed to 2 in 123 now u can take 2 element at a time that is 2 and 3 and u make the number 23 and check whether it is less than 26 or not and yes it is less so you make a recursive call again buy incrementing I by 2 as u r taking 2 at a time so i became 3 and it hit base case and aw is print
Just make recursive stack u will understand
thankyou so much for explaination…