Untitled

mail@pastecode.io avatarunknown
plain_text
2 months ago
388 B
0
Indexable
Never
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);
}