PIXELBANKv9.1.0
Menu

Evaluate Reverse Polish Notation

Evaluate an arithmetic expression in Reverse Polish Notation (postfix). Valid operators: +, -, *, /. Division truncates toward zero.

Example:

Input:
2,1,+,3,*
Output:
9
Reasoning:
  • The input is processed from left to right, with the first two values 2 and 1 being added together using the + operator, resulting in 2+1=32 + 1 = 3.
  • The result 3 is then multiplied by 3 using the * operator, giving 3â‹…3=93 \cdot 3 = 9.
  • The final output is 99.

Constraints:

  • 1 <= len(tokens) <= 10^4
  • Tokens are integers or operators
solution.py

Test Results

0/0
Run code to see test results.
Evaluate Reverse Polish Notation - Medium | PixelBank