File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 5
5
Problem: https://leetcode.com/problems/min-stack/description/
6
6
"""
7
7
8
- stack = []
9
- min_stack = []
8
+ stack : list [ int ] = []
9
+ min_stack : list [ int ] = []
10
10
11
11
12
- def push (value : int ):
12
+ def push (value : int ) -> None :
13
13
"""
14
14
Push into the main stack and track the minimum.
15
15
If the value to insert < minimum, then push to min stack
16
16
Returns None
17
+
18
+ >>>
17
19
"""
18
20
if len (stack ) == 0 :
19
21
min_stack .append (value )
@@ -25,13 +27,15 @@ def push(value: int):
25
27
stack .append (value )
26
28
27
29
28
- def pop ():
30
+ def pop () -> None :
29
31
"""
30
32
Pop from the stack.
31
33
If the popped value is the same as the min stack top,
32
34
pop from the min stack as well
33
35
34
36
Returns None
37
+
38
+ >>>
35
39
"""
36
40
if len (stack ) == 0 :
37
41
print ("Nothing on stack" )
@@ -42,7 +46,7 @@ def pop():
42
46
min_stack .pop ()
43
47
44
48
45
- def get_min ():
49
+ def get_min () -> int :
46
50
"""
47
51
Return the minimum element of the main stack by
48
52
returning the top of the minimum stack
You can’t perform that action at this time.
0 commit comments