leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
0155.cpp (283B)
0 class MinStack { 1 stack<pair<int, int>> st; 2 3 public: 4 MinStack() {} 5 void push(int val) { st.push({val, !st.size() ? val : min(val, st.top().second)}); } 6 void pop() { st.pop(); } 7 int top() { return st.top().first; } 8 int getMin() { return st.top().second; } 9 };