题目描述
blablabla
样例
class MinStack {
Stack<Integer> stack;
Stack<Integer> min;
/** initialize your data structure here. */
public MinStack() {
stack = new Stack<>();
min = new Stack<>();
}
public void push(int x) {
stack.push(x);
if(min.isEmpty()||x<=min.peek())
min.push(x);
}
public void pop() {
int x=stack.pop();
if(x==min.peek())
min.pop();
}
public int top() {
return stack.peek();
}
public int getMin() {
return min.peek();
}
}
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度分析:blablabla
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度分析:blablabla
C++ 代码
blablabla