Ejemplo n.º 1
0
def test_solution():
    obj = MinStack()
    obj.push(-2)
    obj.push(0)
    obj.push(3)
    print(obj.stack)
    print(obj.getMin())
    print(obj.pop())
    print(obj.top())
    print(obj.getMin())
Ejemplo n.º 2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from solution import MinStack
from solution import LinkNode

st = MinStack()
st.push(1)
st.push(2)
st.push(0)
print(st.top())
print(st.getMin())
st.pop()
print(st.getMin())
Ejemplo n.º 3
0
    def test1(self):
        ms = MinStack()
        ms.push(2)
        ms.push(6)
        ms.push(4)
        ms.push(1)
        ms.push(5)
        ms.push(1)

        res = ms.get_min()
        self.assertEqual(1, res)

        ms.pop()
        res = ms.get_min()
        self.assertEqual(1, res)

        ms.pop()
        res = ms.get_min()
        self.assertEqual(1, res)

        ms.pop()
        res = ms.get_min()
        self.assertEqual(2, res)

        ms.pop()
        res = ms.get_min()
        self.assertEqual(2, res)

        res2 = ms.pop()
        self.assertEqual(6, res2)
        res = ms.get_min()
        self.assertEqual(2, res)

        res2 = ms.pop()
        self.assertEqual(2, res2)