Skip to main content

Reverse Polish Notation Calculator

MIDDLE
CiklumN-iX

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

Valid operators are +, -, *, and /. Each operand may be an integer or another expression.

Division should truncate toward zero.

Example:

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

Examples:

Input 1:{"tokens":["2","1","+","3","*"]}
Output 1:9
Input 2:{"tokens":["4","13","5","/","+"]}
Output 2:6

Loading editor...

Run your code to see results

Click the Run button above