Medium
Evaluate Reverse Polish Notation
Medium
62 submissions
25 coins
+100 XP
Math
Stack
Problem Description
Evaluate an arithmetic expression written in Reverse Polish Notation. Operators are `+`, `-`, `*`, `/`; division between integers **truncates toward zero**. The expression is always valid and never divides by zero.
**Example 1:**
```
Input: tokens = ["2", "1", "+", "3", "*"]
Output: 9
```
**Example 2:**
```
Input: tokens = ["4", "13", "5", "/", "+"]
Output: 6
```
**Example 3:**
```
Input: tokens = ["7", "-2", "/"]
Output: -3
```
Constraints
- `1 <= tokens.length <= 10^4`
- Every intermediate result fits in a 32-bit integer.
Need help?
Connect with expert programmers for real-time collaborative coding, video meetings, and whiteboard sessions via CodeConnect.
Video Call
Whiteboard
Live Coding
Screen Share