Logic of duplicate char formatting problem

i could not think of the logic of the problem so i unlocked editorial and when i studied the code i could not understand how recursion is working in that code . please look and tell me .


This is my code for the same problem. We simply have to add * between same consecutive characters. Our base case for the recursive function will simply be when we have reached the end of the string. And now we are left with only two conditions - when s[i] == s[i+1] and when s[i] != s[i+1] So we work accordingly. Please check the code.