标签:int str oid alt new return logs turn init
题目描述:
class MinStack { public: /** initialize your data structure here. */ MinStack() { } void push(int x) { data.push(x); if(min_data.empty()){ min_data.push(x); } else{ if(min_data.top() > x) min_data.push(x); else min_data.push(min_data.top()); } } void pop() { data.pop(); min_data.pop(); } int top() { return data.top(); } int getMin() { return min_data.top(); } private: stack<int> data; stack<int> min_data; }; /** * 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(); */
标签:int str oid alt new return logs turn init
原文地址:http://www.cnblogs.com/strongYaYa/p/6780148.html