class MinStack {
public:
/*
* @param a: An integer
*/
//MinStack(int a) {
// do intialization if necessary
//}
/*
* @param number: An integer
* @return: nothing
*/
void push(int number) {
// write your code here
stackNum.push(number);
if (minStack.empty()) {
minStack.push(stackNum.top());
} else {
if (minStack.top() <= stackNum.top()) {
minStack.push(minStack.top());
} else {
minStack.push(stackNum.top());
}
}
}
/*
* @param a: An integer
* @return: An integer
*/
int pop() {
// write your code here
int popNum = stackNum.top();
stackNum.pop();
minStack.pop();
return popNum;
}
/*
* @param a: An integer
* @return: An integer
*/
int min() {
// write your code here
return minStack.top();
}
private:
stack<int> stackNum;
stack<int> minStack;
};