Skip to content

Commit c355920

Browse files
committed
Thankyou to python list
1 parent 2a7318c commit c355920

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

155. Min Stack.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
class MinStack:
2+
3+
def __init__(self):
4+
"""
5+
initialize your data structure here.
6+
"""
7+
self.stack = []
8+
9+
def push(self, x):
10+
"""
11+
:type x: int
12+
:rtype: void
13+
"""
14+
self.stack.append(x)
15+
16+
def pop(self):
17+
"""
18+
:rtype: void
19+
"""
20+
self.stack.pop()
21+
22+
def top(self):
23+
"""
24+
:rtype: int
25+
"""
26+
return self.stack[-1]
27+
28+
def getMin(self):
29+
"""
30+
:rtype: int
31+
"""
32+
s = min(self.stack)
33+
return s
34+
35+
36+
# Your MinStack object will be instantiated and called as such:
37+
# obj = MinStack()
38+
# obj.push(x)
39+
# obj.pop()
40+
# param_3 = obj.top()
41+
# param_4 = obj.getMin()

0 commit comments

Comments
 (0)