Not able to get the approach

Not able to get the approach with this problem

@shubhamkumarsingh Hey bro wassup!
No problem I will give you an approach.
Basically what you have to do is, take out the 0th character of the number string every time, fetch the code for it.

So for example :- for 12

  • you fetch 1, now code for 1 is say “abc”,
  • now loop through the code and for each iteration make recursive call say keypad(ros, ans + code.charAt(i)).
  • the base case will be when the number string’s length becomes 0, then you will print the answer.

Here I am adding a code snippet for reference.

if (str.length() == 0) {

	System.out.print(ans+" ");

	return;
}

char ch = str.charAt(0);
String ros = str.substring(1);

String code = getcode(ch);

for (int i = 0; i < code.length(); i++) {
	keypad(ros, ans + code.charAt(i));

}

If your doubt is cleared then mark it resolved buddy!
Happy coding!