Can you please have a look on the approach implemented here for the same problem. https://ide.codingblocks.com/s/125310. With Recursion i think becoming more and more complicated for understanding.
Much Simpler Implementation
Its on you whether recursion is easier for you or any other method , main think is getting AC.
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.