Recursion-Duplicate Character formating

sir what is the mistake in my code

mistakes

  1. you doesn’t intialize i with 0
    hence i contains garbage

  2. you n will never become 0 for finite string hence it stuck in infinite loop

  3. you are only comparing 0th and 1st character every time

  4. NO need to return any character

also your approach is not correct

check this Reference Code

i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask