leetcode-155. 最小栈
题目:
代码:
#include <iostream>
#include <stack>
#include <cmath>
using namespace std;
stack<int> s;
stack<int> s_min;
MinStack(){
s_min.push(INT_MAX);
}
void push(int val) {
s.push(val);
s_min.push(min(s_min.top(),val));
}
void pop() {
s.pop();
s_min.pop();
}
int top() {
return s.top();
}
int getMin() {
return s_min.top();
}
int main(){
return 0;
}