#include <bits/stdc++.h>using namespace std;int main(){string s;cin>>s;int len = s.length();for(int i=0;i<len;){if(s[i]==s[i+1] && i>-1){s.erase(i,2);i--; }else{i++; }}if(!s.empty())cout<<s<<"\n";elsecout<< "Empty String"<<"\n";return 0;}
References:
std::string::erase in C++
No comments:
Post a Comment
Guys, if you have any doubts or suggestions please let us know.