Please help in finding the error. https://ide.codingblocks.com/s/85699
Run time error after submission
Hi Mudit,
Your code shows stack overflow error for a very small string also so instead of using string builder use string only and check if at a particular index there is character p and at index + 1 there is character i and if it comes true then form a new string such that in place of pi there is 3.14 and you can do this by using substring function.
I dont know why it is giving me stack overflow error, can you please explain and also isnt stringbuilder better and faster than string. I have implemented the above approach it is updating the string but not returning the updated string. return type is void. https://ide.codingblocks.com/s/85959
Hi Mudit,
Either print the string when i >= str.length() or return the final string by changing the return type to string as changes made in string in the recursive function will not persist in main function.
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.