I see the editorial coz im not able to solve , but still im not able to understand the editorial ? pls help me im very confused in the editorial code
Can't understand
hey @nigamshubham1998
This is a simple recursion questions. There is no need to use HashMap.
in mapped strings problem, it is given that numbers from 1 to 26 which are correspondingly mapped from A to Z.
1 -> A
2 -> B
3 -> C
.
.
25 -> Y
26 -> Z
Now you have to print all the possible strings which we can form from given input number.
For eg.
input : 123
Now, the different ways in which we can divide string 123 are:
1-2-3 => A-B-C
1-23 => A-W
12-3 => L-C
Approach Discussion
- 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.