java 的
import java.util.Stack; public class Solution { private Stack <Integer>stack; private Stack<Integer> minStack; private int curMin; { stack = new Stack(); minStack = new Stack(); curMin = Integer.MAX_VALUE; } public void push(int node) { stack.push(node); if(curMin>node){ curMin = node; } minStack.push(curMin); } public void pop() { stack.pop(); minStack.pop(); curMin = minStack.peek(); } public int top() { return stack.peek(); } public int min() { return curMin; } }