We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int q;
cin >> q;
for (int i = 0; i < q; i++){
int t;
cin >> t;
if (t == 2 || t == 3) v.push_back({t, 0});
else {
int x; cin >> x;
v.push_back({t, x});
}
}
vector<int> r;
for (int i = 0; i < v.size(); i++){
if (v[i].first == 1)
r.push_back(v[i].second);
else if (v[i].first == 2)
r.erase(r.begin());
else if (v[i].first == 3){
auto it = r.begin();
cout << *it << endl;
}
return 0;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Queue using Two Stacks
You are viewing a single comment's thread. Return to all comments →
vector> v;