Evaluate Reverse Polish Notation Problem

Evaluate Reverse Polish Notation Problem — ExecCode Medium DSA Practice

Solve the Evaluate Reverse Polish Notation problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression.

Examples

Input tokens = ["2", "1", "+", "3", "", "4", "+"]; Output 13. Input tokens = ["2", "1", "+", "3", ""]; Output 9

Constraints

1 ≤ tokens.length ≤ 10⁴ Division truncates toward zero.

Practice Evaluate Reverse Polish Notation free on ExecCode. Browse DSA problems, topic map, and placement guides.