Stack
LC #150Medium
Evaluate Reverse Polish Notation
Stack
Problem
Evaluate the value of an arithmetic expression in Reverse Polish Notation (postfix).
arraymathstack
Constraints
- ›1 ≤ tokens.length ≤ 10⁴
- ›tokens[i] is either an operator: "+", "-", "*", or "/", or an integer in [-200, 200].
Example
Input
tokens = ["2", "1", "+", "3", "*"]Output
9Why
((2 + 1) * 3) = 9