Untitled
unknown
plain_text
2 years ago
388 B
7
Indexable
void push_bot(stack<int> &s,int x){
if(s.empty()){
s.push(x);
return;
}
int num=s.top();
s.pop();
push_bot(s,x);
s.push(num); //just pushing to bottom no reverse
}
void reverseStack(stack<int> &stack) {
if(stack.empty()) return;
int t=stack.top();
stack.pop();
reverseStack(stack);
push_bot(stack,t);
}Editor is loading...