Replace all occurences of pi

Can you explain me what is the approach to follow to solve these types of questions?

@prateekad99,
You can use a recursive solution where the base case will be if length of string is less than equal to 1.
If the char at position 0 is ‘p’ and char at pos is ‘i’ return 3.14 + recursive call with substring from position 2.
Try to think about the else case yourself. If you face any problem, attempt the question and share your code with me

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.