单调栈维护最小值

class Solution {
public:
    vector<int> getMinStack(vector<vector<int> >& op) {
        vector<int> ans;
        stack<int> st,minn;
        for(auto i:op)
        {
            if(i[0] == 1)
            {
                st.push(i[1]);
                if(minn.empty() || i[1] <= minn.top())
                    minn.push(i[1]);
            }
            else if(i[0] == 2)
            {
                if(!minn.empty() && st.top() == minn.top())
                    minn.pop();
                st.pop();
            }
            else ans.push_back(minn.top());
        }
        return ans;
    }
};