40. Evaluate Reverse Polish Notation

Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are: +, -, *, /. Each operand may be an integer. Division between two integers truncates toward zero.
Example 1
Input: tokens = ["2","1","+","3","*"]
Output: 9
Explanation: First 2 + 1 = 3, then 3 * 3 = 9.
Example 2
Input: tokens = ["4","13","5","/","+"]
Output: 6
Explanation: 13 / 5 = 2 (truncate toward zero), then 4 + 2 = 6.
arraysmediumstack
JavaScript
Loading...
Line 1, Char 1