leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0155.cpp (283B)


      1 class MinStack {
      2     stack<pair<int, int>> st;
      3 
      4   public:
      5     MinStack() {}
      6     void push(int val) { st.push({val, !st.size() ? val : min(val, st.top().second)}); }
      7     void pop() { st.pop(); }
      8     int top() { return st.top().first; }
      9     int getMin() { return st.top().second; }
     10 };