code link: https://ide.codingblocks.com/s/85524
can you still me any better approach to this problem using recursion and without using recursion.
My is working. can you still me any better approach to this problem using recursion and without using recursion
Hi @shantanu.kaushik21,see you in the function you can have a variable cc=str.charAt(0) now if cc==‘x’ then call the function again using str.substring(1) and store that ans in String ans and then do ans=ans+‘x’ else you call the function with str.substring(1) and store that ans in String ans and later do ans=cc+ans.
See this for your reference: