DOUBT IN A RECURSION CODE

Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.

Attempt link:
https://ide.geeksforgeeks.org/3t5DWMyHaj

PLEASE HELP ME UNDERSTAND WHY MY SOLUTION IS NOT WORKING

logic is correct only one mistake

for(int j=0;j<str.length();j++){
solve(s,o+str[j],i+1,N,ans);
}
here don’t use i
use another variable like j because i is also a parameter in function

Modified Code

Thanks a lot sir
Now I am getting correct answer. I did not realize this mistake before

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.