题目
class MinStack {
public:
MinStack() {
}
void push(int x) {
m_stkValue.push(x);
if (m_stkMinVal.empty() || x < m_stkMinVal.top())
m_stkMinVal.push(x);
else
m_stkMinVal.push(m_stkMinVal.top());
}
void pop() {
m_stkValue.pop();
m_stkMinVal.pop();
}
int top() {
return m_stkValue.top();
}
int getMin() {
return m_stkMinVal.top();
}
private:
std::stack<int> m_stkValue;
std::stack<int> m_stkMinVal;
};