Dashboard
LC #150

Evaluate Reverse Polish Notation

Pattern · ?

Problem

Evaluate the value of an arithmetic expression in Reverse Polish Notation (postfix).

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
9
Why
((2 + 1) * 3) = 9

Spot the pattern

Which pattern cracks it?

Hints

One at a time
Solve on LeetCode ↗