Duplicate character formatting doubt

Here’s a link to my code https://ide.codingblocks.com/s/80011
If I’m giving abc as input, the output is coming out to be aababc.
Please tell me what’s going wrong?

hi pulkit
there are issues with your current logic. it is not producing correct output for sample test case also.
you can refer this algorithm

If length of the string is 1, return the string.
Self work is to check if the first two characters of the string are equal. If they are, insert a * between the two characters. Then, perform a recursive call for the rest of the string excluding the two characters.
Else perform the recursive call for the next character.

if you still don’t understand let me know in that case

Thanks for your help.

Turns out, my logic was right, but there was some issue with my string s2 re-appending the characters with each function call.

Fixed it here. https://ide.codingblocks.com/s/80338. Passed all test cases

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.