题解 | 点击消除
点击消除
https://www.nowcoder.com/practice/8d3643ec29654cf8908b5cf3a0479fd5
#include <iostream>
using namespace std;
#include <stack>
#include <string>
int main(){
string s;
cin>>s;
stack<char>a;
for(char c:s){
if(!a.empty()&&a.top()==c)a.pop();
else a.push(c);
}
string res;
while(!a.empty()){
res=a.top()+res;
a.pop();
}
cout<<(res.empty()?"0":res)<<endl;
return 0;
}
// 64 位输出请用 printf("%lld")

查看9道真题和解析