loading…
Write eval_rpn(tokens) for tokens like ["2", "1", "+", "3", "*"]. Operators are + - * /; division truncates toward zero.
eval_rpn(["2", "1", "+", "3", "*"]) -> 9 # (2 + 1) * 3
eval_rpn(["4", "13", "5", "/", "+"]) -> 6 # 4 + 13 / 5
Stuck on the idea itself? The stack lesson walks through the pattern from scratch.