Skip to content

Commit f5220e1

Browse files
committed
added type hints
1 parent 23b45d0 commit f5220e1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

data_structures/stacks/min_constant_time.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
Problem: https://leetcode.com/problems/min-stack/description/
66
"""
77

8-
stack = []
9-
min_stack = []
8+
stack: list[int] = []
9+
min_stack: list[int] = []
1010

1111

12-
def push(value: int):
12+
def push(value: int) -> None:
1313
"""
1414
Push into the main stack and track the minimum.
1515
If the value to insert < minimum, then push to min stack
1616
Returns None
17+
18+
>>>
1719
"""
1820
if len(stack) == 0:
1921
min_stack.append(value)
@@ -25,13 +27,15 @@ def push(value: int):
2527
stack.append(value)
2628

2729

28-
def pop():
30+
def pop() -> None:
2931
"""
3032
Pop from the stack.
3133
If the popped value is the same as the min stack top,
3234
pop from the min stack as well
3335
3436
Returns None
37+
38+
>>>
3539
"""
3640
if len(stack) == 0:
3741
print("Nothing on stack")
@@ -42,7 +46,7 @@ def pop():
4246
min_stack.pop()
4347

4448

45-
def get_min():
49+
def get_min() -> int:
4650
"""
4751
Return the minimum element of the main stack by
4852
returning the top of the minimum stack

0 commit comments

Comments
 (0)