Please find the error and explain right algorithm

Hey @rsumitaj
I did 3 changes in your code and mentioned them in comments .
Check this :https://ide.codingblocks.com/s/319607
We are saving current index because in while loop var i will reach end of string and if we call remove(string,I) then we will not be processing further string for duplicates in further recursion calls because var i is already at last element of string .
I hope this resolves you query.