Doubt in shifting elements.From line 7 to 15 of code ,is there any better way or easy way to do this part

hello @Ashu1318
check this->
image

  • Traverse the string. At each instance check whether substring starting from index 0 till index 2 is same as β€œpi”.
  • If so , obtain the result for remaining string from index 2 i.e. s.substring(2) recursively . Store this result in say β€˜ros’ . Now return β€œ3.14” + ros.
  • If however , it was not so , obtain the result for the remaining string starting from index 1 and add s[0] to it i.e. return s[0] + ros.