Question DSA-STK-0011
MediumWhat is the output of this code?
tokens = "2 3 4 * +".split()
st = []
for t in tokens:
if t in "+-*":
b, a = st.pop(), st.pop()
st.append(a + b if t == "+" else a - b if t == "-" else a * b)
else:
st.append(int(t))
print(st[0])
- A.
14
- B.
20
- C.
Sign up free to see the answer and a step-by-step explanation.