#include <climits>
#include <bits/stdc++.h>
class Solution {
public:
    void push(int value) {
        
        stack1.push(value);
        // 更新最小值
        smin = std::min(smin, value);
        
    }
  // 我这样做就到O(n)了 不满足进阶要求
    void pop() {
        int tmp = stack1.top();
        stack1.pop();
        if(tmp==smin)
        {
            smin = INT_MAX;
            // 若出栈的就是当前最小值
            //那就需要对余下元素在统计下
            // 1 转到2
            while(!stack1.empty())
            {
                int a = stack1.top();
                smin = std::min(a, smin);
                stack2.push(a);
                stack1.pop();
            }
        }
        
        // 再把2转到1
        while(!stack2.empty())
        {
            int a = stack2.top();
            stack1.push(a);
            stack2.pop();
        }

        
    }
    int top() {

        return stack1.top();
        
    }
    int min() {

        return smin;
        
    }

private:
    stack<int> stack1;
    stack<int> stack2; // 始终维护当前最小值
    // 就用一个成员变量来维护吧
    int smin = INT_MAX;
};

第二个栈用来当需要弹出当前最小值 需要遍历取出一遍 更新最小值