We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2a7318c commit c355920Copy full SHA for c355920
155. Min Stack.py
@@ -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
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
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