Untitled

 avatar
unknown
plain_text
9 months ago
583 B
0
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