Pattern Recognition Drill
Medium Stacks & Queues
The Problem
Evaluate an arithmetic expression in Reverse Polish Notation (postfix).
What approach would you use?
Think about it before scrolling down.
Push numbers. On operator, pop two, compute, push result. O(n).
Common Trap
Division truncates toward zero in RPN. In Python, use int(a/b) not a//b (which floors).