Keypad problem.....recursion


test case 1 is not passing

Check now.

what mistake i was doing??

When there is a 0… you have to include " " a white space.So i commented out line 18 to 22

is there any other way to do this question??

Recursion is only way since there are alot of combinations. Optimization can be done by Dynamic Programming.
You can refer this https://www.geeksforgeeks.org/mobile-numeric-keypad-problem/

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.