剑指offer 包含min函数的栈
class Solution {
private:
vector<int> vec;
public:
void push(int value) {
vec.emplace_back(value);
}
void pop() {
if(vec.empty()) return;
vec.erase(vec.end()-1);
}
int top() {
if(vec.empty()) return 0;
return *(vec.end()-1);
}
int min() {
if(vec.empty()) return 0;
return *min_element(vec.begin(), vec.end());
}
};