This is the solution of problem replace all pi by recursion.I am not able to figure out why the error is giving up index out of bound.
Replace All PI Problem by recursion
Your code tries to access res.substring(0,2 ) even when res is empty
I got it Thank You So Much for helping