Skip to content

Latest commit

 

History

History
28 lines (23 loc) · 640 Bytes

File metadata and controls

28 lines (23 loc) · 640 Bytes

#Reverse a stack PRACTICE

 void insert(stack<int> &s,int temp)
    {
        if(s.size()==0)
        {
             s.push(temp);
             return;
        }
            
        int ele=s.top();
        s.pop();
        insert(s,temp);
        s.push(ele);
    }
    
    void Reverse(stack<int> &s){
        
       if(s.size()==0)
            return;
        
        int temp=s.top();
        s.pop();
        Reverse(s);
        insert(s,temp);
    }
    ```