sir what is the mistake in my code
Recursion-Duplicate Character formating
mistakes
-
you doesn’t intialize i with 0
hence i contains garbage -
you n will never become 0 for finite string hence it stuck in infinite loop
-
you are only comparing 0th and 1st character every time
-
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