We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e0e259f commit e71c1dbCopy full SHA for e71c1db
Leetcode_30days/day10_MinStack.py
@@ -0,0 +1,52 @@
1
+class MinStack(object):
2
+
3
+ def __init__(self):
4
+ """
5
+ initialize your data structure here.
6
7
+ self.A =[]
8
9
+ def push(self, x):
10
11
+ :type x: int
12
+ :rtype: None
13
14
+ self.A.append(x)
15
16
17
+ def pop(self):
18
19
20
21
+ if self.A:
22
+ self.A.pop()
23
24
25
+ def top(self):
26
27
+ :rtype: int
28
29
30
+ return self.A[-1]
31
+ else:
32
+ return None
33
34
35
36
+ def getMin(self):
37
38
39
40
41
+ return min(self.A)
42
43
44
45
46
47
+# Your MinStack object will be instantiated and called as such:
48
+# obj = MinStack()
49
+# obj.push(x)
50
+# obj.pop()
51
+# param_3 = obj.top()
52
+# param_4 = obj.getMin()
0 commit comments