Evaluate Reverse Polish Notation

Medium
Stacks Array Stack Math

Evaluate RPN expression. Operators: + - * /

Constraints

1 ≤ tokens.length ≤ 10^4

Examples

Example 1:
Input: 2 1 + 3 *
Output: 9
Explanation: ((2+1)*3)=9
Example 2:
Input: 4 13 5 / +
Output: 6
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.