Day 30 Python Answers - 60515687 - 2025 - 05 - 13 - 08 - 53
Day 30 Python Answers - 60515687 - 2025 - 05 - 13 - 08 - 53
Day 30
Syllabus Coverage
stack = []
if char.isdigit():
stack.append(int(char))
else:
b = stack.pop()
a = stack.pop()
if char == '+':
stack.append(a + b)
stack.append(a - b)
stack.append(a * b)
stack.append(a // b)
return stack.pop()
print(evaluate_postfix("23+5*")) # Output: 25
Output:
25
stack = []
min_stack = []
stack.append(val)
min_stack.append(val)
def pop() -> None:
if stack.pop() == min_stack[-1]:
min_stack.pop()
return stack[-1]
return min_stack[-1]
# Test
push(-2)
push(0)
push(-3)
print(get_min()) # Output: -3
pop()
print(get_min()) # Output: -2
Output:
-3
-2