Recursively remove all adjacents dublicates

class Solution{
public:
string remove(string s){
// code here
int i=1,j=2;
int n=s.size();
string res_str="";
if(s[0]!=s[1])
res_str+=s[0];
while(i<s.size()){
if(s[i]!=s[j] && s[i]!=s[i-1] ){
res_str=res_str+s[i];
}
i++;
j++;
}
if(n>2 && s[n-1]!=s[n-2])
res_str=res_str+s[n-1];
if(res_str==s)return res_str;
for(int i=0;i<res_str.size();i++){
if(res_str[i]==res_str[i+1])
res_str=remove(res_str);
}

    return res_str;
    }

// j<s.size() && 

};

remove the omment code here to see it in proper manner

please tell the mistake i am doing

it is question from gfg

hi @ashish2101
kindly share the question link. I will look into it.

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.