Evaluate Reverse Polish Notation

Stacks · medium

Implement `evalRPN(tokens)` that evaluates an expression in **Reverse Polish Notation**. Tokens are strings: either numbers or one of `+`, `-`, `*`, `/`. Division truncates toward zero. Example: `evalRPN(["2","1","+","3","*"])` → `9`.

Hints
  • Push operands onto the stack.
  • When you see an operator, pop two values, apply the operator, and push the result.
Loading...

Run your code to see results.