How to remove the for loop in base case here
hello @Vikaspal
there is no way to remove it.
instead try this
We follow a recursive approach to solve this problem. At each instance , we check whether the first character is a ‘x’ or not. We recursively obtain the result for the rest of the string i.e. the substring from index 1. If the first character of our current string is an ‘x’ , we concatenate it to the end of our resultant string. Else , we simply place concatenate it back to the front of our resultant string. The second part of the string is the result we obtained recursively.
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.