Untitled
unknown
plain_text
2 years ago
583 B
4
Indexable
#include<iostream>
#include<stack>
#include<algorithm>
using namespace std;
int main(){
string str;
cin>>str;
stack<int> s;
for (auto it : str) {
if (it >= 'a' && it <= 'z') {
s.push(it);
} else {
if (!s.empty()) {
s.pop();
}
}
}
str = "";
while (!s.empty()) {
str.push_back(s.top());
s.pop();
}
reverse(begin(str), end(str));
cout<<str<<endl;
}Editor is loading...
Leave a Comment