https://leetcode.com/problems/min-stack/?envType=study-plan-v2&envId=top-interview-150
class MinStack {
List<Integer> stack;
PriorityQueue<Integer> q;
public MinStack() {
stack = new ArrayList();
q = new PriorityQueue();
}
public void push(int val) {
q.add(val);
stack.add(val);
}
public void pop() {
int val = stack.get(stack.size() - 1);
stack.remove(stack.size() - 1);
q.remove(val);
}
public int top() {
return stack.get(stack.size() - 1);
}
public int getMin() {
return q.peek();
}
}
/**
* Your MinStack object will be instantiated and called as such:
* MinStack obj = new MinStack();
* obj.push(val);
* obj.pop();
* int param_3 = obj.top();
* int param_4 = obj.getMin();
*/