Remove duplicates prob

#include
#include

using namespace std;

void work(string &s,string &o,int n,int i)
{

if(i==n)
return;

if(s[i]==s[i+1])
return work(s,o,n,i+1);
else
o+=s[i];

}

int main()
{
string s;
cin>>s;

string o="";
int n=s.length();
work(s,o,n,0);
cout<<o<<endl;


return 0;

}

whats wrong in code…?

@ynikhil1999 hey nikhil there is no such need to take new string for output you can output you input string
just pass your input string in function and i+1 n and in function remove else part do cout<<s[i];
and make a call after printing work(s,i+1,n)
and above do return s,i+1,n when s[i]==s[i+1]

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.