。。。栈的经典题吧
把当前的字符跟栈顶比较,一样就把栈顶弹出,不一样就把该字符压入栈。

#include<bits/stdc++.h>
using namespace std;
char s[300005];
int main(){

   cin>>s;
    int len=strlen(s);
    stack<char> st;
    for(int i=0;i<len;i++){
        if(st.size() && st.top()==s[i]) st.pop();
        else st.push(s[i]);
    }
    stack<char> q;
    while(!st.empty()){
        q.push(st.top());
        st.pop();
    }
    if(q.empty()){
        cout<<0;
        return 0;
    }
    while(!q.empty()) cout<<q.top(),q.pop();
    return 0;
}