You are viewing a single comment's thread. Return to all comments →
can you explain where it is wrong
using namespace std; int main() {
int n; cin>>n; stack<int> s1; stack<int> s2; while(n--) { int q,e; cin>>q; if(q==1){ cin>>e; while(!s1.empty()){ s2.push(s1.top()); s1.pop(); } s1.push(e); while(!s2.empty()){ s1.push(s2.top()); s2.pop(); } } if(q==2){ s1.pop(); } if(q==3){ cout<<s1.top()<<endl; } } return 0;
}
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 →
can you explain where it is wrong
include
include
include
include
include
using namespace std; int main() {
}