TEST_F(SolutionTest, case1) { MinStack mstack; for (int i = 100; i >= 0; i--) { mstack.push(i); EXPECT_EQ(mstack.getMin(), i); EXPECT_EQ(mstack.top(), i); } EXPECT_EQ(mstack.getMin(), 0); EXPECT_EQ(mstack.top(), 0); mstack.pop(); EXPECT_EQ(mstack.getMin(), 1); EXPECT_EQ(mstack.top(), 1); }
TEST_F(SolutionTest, case2) { MinStack mstack; for (int i = 0; i < 100; i++) { mstack.push(i); EXPECT_EQ(mstack.getMin(), 0); EXPECT_EQ(mstack.top(), i); } EXPECT_EQ(mstack.getMin(), 0); EXPECT_EQ(mstack.top(), 99); mstack.pop(); EXPECT_EQ(mstack.getMin(), 0); EXPECT_EQ(mstack.top(), 98); }
int main() { MinStack minStack; minStack.push(-2); minStack.push(0); minStack.push(-3); cout << minStack.getMin() << "--> Returns -3" << endl; minStack.pop(); cout << minStack.top() << "--> Returns 0" << endl; cout << minStack.getMin() << "--> Returns -2" << endl; }
int main(){ MinStack stack; stack.push(-2); stack.push(0); stack.push(-1); std::cout << stack.getMin() << std::endl; std::cout << stack.top() << std::endl; stack.pop(); std::cout << stack.getMin() << std::endl; return 0; }
TEST(leetcode_155_min_stack, Basic) { MinStack *minStack = new MinStack(); minStack->push(-2); minStack->push(0); minStack->push(-3); EXPECT_EQ(-3, minStack->getMin()); minStack->pop(); EXPECT_EQ(0, minStack->top()); EXPECT_EQ(-2, minStack->getMin()); }
int main() { MinStack minStack; minStack.push(-2); minStack.push(0); minStack.push(-3); cout << minStack.getMin() << endl; minStack.pop(); cout << minStack.top() << endl; cout << minStack.getMin() << endl; return 0; }
int main(void) { MinStack engine; engine.push(-2); engine.push(0); engine.push(-1); cout << engine.getMin() << '\n'; cout << engine.top() << '\n'; engine.pop(); cout << engine.getMin() << '\n'; return 0; }
int main() { MinStack * myStack = new MinStack(); myStack->push(5); myStack->push(2); myStack->push(6); myStack->push(10); myStack->push(-1); myStack->PrintQueue(); myStack->PrintStack(); printf("Popping !\n"); myStack->pop(); myStack->PrintQueue(); myStack->PrintStack(); return 0; }
int main() { MinStack minStack; minStack.push(-2); minStack.push(0); minStack.push(-3); cout << minStack.getMin() << endl; // --> Returns -3. minStack.pop(); cout << minStack.top() << endl; // --> Returns 0. cout << minStack.getMin() << endl; // --> Returns -2. return 0; }
int main() { MinStack *st = new MinStack; int ch, data; while (1) { scanf("%d", &ch); if (ch == 1) { scanf("%d", &data); st->push(data); } else if (ch == 2) { st->pop(); } else if (ch == 3) { printf("Head: %d\n", st->peek()); } else if (ch == 4) { printf("Min: %d\n", st->min()); } else if (ch == 5) { break; } } return 0; }
int main(){ MinStack stk; stk.push(3); stk.push(1); stk.push(8); int minS = stk.getMin(); stk.push(7); stk.pop(); stk.pop(); stk.push(12); minS = stk.getMin(); getchar(); return 0; }
int main () { MinStack st; st.push(2);st.push(0);st.push(3); st.push(1); cout << st.top() << endl; cout << st.getMin(); }
int main() { MinStack stack; int oporation; int value; while(1) { cin >> oporation; switch(oporation) { case 0: { cin >> value; stack.push(value); break; } case 1: { stack.pop(); break; } case 2: { value = stack.top(); cout << "top = " << value << endl; break; } case 3: { value = stack.getMin(); cout << "min = " << value << endl; break; } } } return 0; }
int main() { MinStack minstack; minstack.push(3); minstack.pop(); minstack.push(5); minstack.push(3); minstack.push(2); minstack.push(1); minstack.push(4); cout<<"minstack.top():"<<minstack.top()<<endl; cout<<"minstack.getMin():"<<minstack.getMin()<<endl; return 0; }
int main(int argc, char const *argv[]) { MinStack myStack; int n, k; cout << "input n: "; while (cin >> n && n != -1) { myStack.push(n); cout << "input n: "; } cout << "0 - nothing, 1 - pop(), 2 - top(), 3 - getMin()" << endl; while (cin >> k && k != -1) { switch (k) { case 1: myStack.pop(); break; case 2: cout << "top: " << myStack.top() << endl; break; case 3: cout << "min: " << myStack.getMin() << endl; break; case 0: cout << "no process." << endl; break; } cout << "0 - nothing, 1 - pop(), 2 - top(), 3 - getMin()" << endl; } // stack<int> s; // s.push(1); // s.pop(); return 0; }
int main(){ MinStack st; st.push(2); st.push(3); st.pop(); st.push(1); st.push(6); st.pop(); st.push(7); cout<<st.getMin()<<endl; system("pause"); }
int main () { MinStack* obj = new MinStack(); obj->push(0); obj->push(1); obj->push(0); obj->getMin(); obj->pop(); obj->getMin(); return 0; }
int _tmain(int argc, _TCHAR* argv[]) { MinStack stk; stk.push(0); stk.push(1); stk.push(0); int v1 = stk.getMin(); stk.pop(); int v2 = stk.getMin(); cout << "v1 : " << v1 << ", v2 : " << v2 << endl; return 0; }
int main() { MinStack stack; stack.Push(3); stack.Push(2); stack.Push(4); stack.Push(5); stack.Push(1); int top; stack.Pop(top); stack.Pop(top); stack.Pop(top); stack.Pop(top); stack.Pop(top); stack.Pop(top); int min; stack.Min(min); printf("%d\n", min); }
int main() { MinStack minStack; int nums[] = {3, 2, 7, 1, 4, 8, 1}; for (int i = 0; i < sizeof(nums)/sizeof(int); ++i) { minStack.push(nums[i]); cout<<"push "<<nums[i]<<". Current top: "<<minStack.top()<<". Current min: "<<minStack.getMin()<<endl; } while (!minStack.empty()) { cout<<"pop "<<minStack.top(); minStack.pop(); cout<<". Current min: "<<minStack.getMin()<<endl; } return 0; }
int main() { MinStack myStack = MinStack(); cout << "napravio stack" << endl; myStack.push(4); myStack.push(3); myStack.push(2); cout << "min: " << myStack.getMinElem() << endl; myStack.pop(); cout << "min after pop: " << myStack.getMinElem() << endl; return 0; }
int main() { int result; MinStack s; s.push(3); s.push(2); s.push(1); s.push(4); s.show(); //result = s.getMin(); //cout << "the getMin result = " << result << endl; result = s.top(); cout << "the top result = " << result << endl; s.pop(); s.show(); return 0; }
int main(int argc, char *argv[]) { MinStack ms; int r; ms.push(1); r = ms.pop(); assert(r == 1); ms.push(2); ms.push(3); r = ms.min(); assert(r == 2); ms.push(1); r = ms.min(); assert(r == 1); return 0; }
int main() { MinStack<int> msi; int n; cin>>n; for(int i=0;i<n;++i) { int tmp; cin>>tmp; msi.push(tmp); cout<<"min:"<<msi.min()<<endl; } while(!msi.empty()) { cout<<msi.top()<<endl; msi.pop(); } }
int main(int argc, const char * argv[]) { // insert code here...Ω MinStack minStack; minStack.push(0); minStack.push(1); minStack.push(0); minStack.getMin(); minStack.pop(); minStack.getMin(); // while (minStack.size() != 0) { // cout <<"The top is "<< minStack.top()<<" "; // cout<< "The min of the stack now is " << minStack.MinTop()<<" " << endl; // minStack.pop(); // } return 0; }
int Mymain() { MinStack s; s.push(9000); cout << s.getMin() << endl; s.push(10); cout << s.getMin() << endl; s.pop(); cout << s.getMin() << endl; s.push(50); cout << s.getMin() << endl; s.pop(); cout << s.getMin() << endl; s.push(1); cout << s.getMin() << endl; s.pop(); cout << s.getMin() << endl; s.pop(); cout << s.getMin() << endl; }
int main(int argc, char *argv[]) { MinStack s; s.push(5); s.push(4); s.push(6); s.push(2); s.push(10); cout << "top:" << s.top() << endl; cout << "min:" << s.getMin() << endl; s.pop(); cout << "min:" << s.getMin() << endl; s.pop(); cout << "min:" << s.getMin() << endl; s.pop(); cout << "min:" << s.getMin() << endl; s.pop(); cout << "min:" << s.getMin() << endl; return 0; }
int main() { int result; MinStack s; s.push(-10000); s.push(-9999); s.push(-9998); s.push(-9997); s.push(-9996); s.push(-9995); s.push(-9994); s.push(-9993); s.push(-9992); s.push(-9991); s.push(-9990); s.show(); result = s.getMin(); cout << "the getMin result = " << result << endl; result = s.top(); cout << "the top result = " << result << endl; s.pop(); s.show(); return 0; }
int main() { cout << "--- expected output [0, 0, 0, 2]" << endl; MinStack ms; ms.push(2); ms.push(0); ms.push(3); ms.push(0); cout << ms.getMin() << endl; ms.pop(); cout << ms.getMin() << endl; ms.pop(); cout << ms.getMin() << endl; ms.pop(); cout << ms.getMin() << endl; ms.clear(); cout << "--- expected output [2147483647 2147483646 2147483646 2147483647 2147483647 -2147483648 -2147483648 2147483647 " << endl; ms.push(2147483646); ms.push(2147483646); ms.push(2147483647); cout << ms.top() << endl; ms.pop(); cout << ms.getMin() << endl; ms.pop(); cout << ms.getMin() << endl; ms.pop(); ms.push(2147483647); cout << ms.top() << endl; cout << ms.getMin() << endl; ms.push(-2147483648); cout << ms.top() << endl; cout << ms.getMin() << endl; ms.pop(); cout << ms.getMin() << endl; return 0; }
int main() { /*push(2147483646),push(2147483646),push(2147483647),top,pop,getMin,pop,getMin,pop,push(2147483647), top,getMin,push(-2147483648),top,getMin,pop,getMin*/ MinStack ms; ms.push(2147483646); ms.push(2147483646); ms.push(2147483647); ms.top(); ms.pop(); ms.getMin(); ms.pop(); ms.getMin(); ms.pop(); ms.push(2147483647); ms.top(); ms.getMin(); ms.push(-2147483648); ms.top(); ms.getMin(); ms.pop(); ms.getMin(); return 0; }