• + 1 comment

    using namespace std;

    int st[100000]; int top=-1;

    void push() { int input; cin>>input;

    st[++top]=input; //cout<<"in push :"<

    } void pop() { st[top]=' '; top--;

    } void display() { cout<<"\nDisplay "; cout<

    for(i=0;i<=top;i++)
       { 
        if(st[i]>max)
        max=st[i];
       }
    cout<<max<<"\n";
    

    }

    int main() {

    int j; j=0;
    int n; int option;
    cin>>n;
    while(j<n)
    {
    cin>>option;
        switch(option)
        {
    
            case 1:
            {
             push();
             //display();
            }
            break;
            case 2:
            {pop();
             //display();
            }
            break;
            case 3:
            {max();
             //display();
            }
            break;
        }
        j++;
    }
    
    
    
    
    return 0;
    

    }

    Facing timeout problem at the end! Please help :P