ASAPUtils Logo ASAPUtils
Week 3

Evaluate Reverse Polish Notation

Evaluate Reverse Polish Notation with an operand stack, including correct subtraction and division order, truncation toward zero, C++ and JavaScript solutions, and a token-by-token visual trace.

The problem

Given valid postfix-expression tokens containing integers and the operators plus, minus, multiply, and divide, evaluate the expression. Integer division truncates toward zero.

tokens = ["2", "1", "+", "3", "*"] -> 9

Related Problems