https://leetcode.com/problems/min-stack/
#include <vector>
#include <queue>
#include <map>
#include <iostream>
using namespace std;
class MinStack {
public:
vector<int> vec;
priority_queue<int,vector<int>,greater<int> > que,que2;
void push(int x) {
vec.push_back(x);
que.push(x);
}
void pop() {
que2.push(top());
vec.pop_back();
}
int top() {
return vec[vec.size()-1];
}
int getMin() {
while(!que2.empty() && que.top() == que2.top()){
que.pop();que2.pop();
}
return que.top();
}
};