Question DSA-STK-0044
MediumWhat is the output of this code?
st, mins = [], []
def push(x):
st.append(x)
mins.append(x if not mins else min(x, mins[-1]))
def pop():
st.pop(); mins.pop()
for x in [5, 3, 7, 2]:
push(x)
pop()
print(mins[-1], st[-1])
- A.
2 7
- B.
3 2
- C.
Sign up free to see the answer and a step-by-step explanation.