#include<stack>
#include<limit.h>
class MinStack {
public:
stack<int> stack1;
/** initialize your data structure here. */
MinStack() {
}
void push(int x) {
stack1.push(x);
}
void pop() {
stack1.pop();
}
int top() {
return stack1.top();
}
int getMin() {
stack<int> s2;
s2 = stack1;
int min = s2.top();
while(!s2.empty())
{
if(min>s2.top())
{
min = s2.top();
}
s2.pop();
}
return min;
}
};
/**
* Your MinStack object will be instantiated and called as such:
* MinStack* obj = new MinStack();
* obj->push(x);
* obj->pop();
* int param_3 = obj->top();
* int param_4 = obj->getMin();
*/