题解 | #点击消除#
点击消除
http://www.nowcoder.com/practice/8d3643ec29654cf8908b5cf3a0479fd5
#include <bits/stdc++.h>
using namespace std;
int main()
{
stack<char> st;
string s;
cin>>s;
for (auto& c: s) {
bool flag = true;
while (!st.empty() && st.top() == c) {
st.pop();
flag = false;
}
if (flag) st.push(c);
}
s = "";
while (!st.empty()) {
s = st.top() + s; st.pop();
}
if (s.size() > 0) cout<<s<<endl;
else cout<<0<<endl;
return 0;
}