Skip to interview prep
Apexed

54. Evaluate Reverse Polish Notation

MediumStacks

Evaluate an expression in postfix (Reverse Polish) notation. Tokens are integers or "+", "-", "*", "/". Division truncates toward zero.

Example 1

Input: tokens = ["2", "1", "+", "3", "*"]
Output: 9
Explanation: (2 + 1) × 3

Constraints

  • The expression is valid

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 4 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Evaluate Reverse Polish Notation — coding interview practice — Apexed