题目
题解
import java.util.Stack;
public class Solution {
Stack<Integer> stack = new Stack();
Stack<Integer> helpStack = new Stack();
public void push(int node) {
int helpStackTop = node;
if (!helpStack.isEmpty()) {
helpStackTop = Math.min(helpStack.peek(), helpStackTop);
}
stack.push(node);
helpStack.push(helpStackTop);
}
public void pop() {
if (stack.isEmpty()) {
return;
}
stack.pop();
helpStack.pop();
}
public int top() {
return stack.peek();
}
public int min() {
return helpStack.peek();
}
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。