Reverse Polish Calculator

L5 Medium Stack
Concept
Reverse Polish notation puts operators after their operands, which is exactly what a stack evaluates naturally: push numbers, apply operators to the top two.
Given an array of strings tokens formed from integers and the operators +, -, *, / in Reverse Polish notation, evaluate it and return the resulting integer. Division truncates toward zero.
Examples
▸ tokens = ["2", "1", "+", "3", "*"]
→ 9
▸ tokens = ["4", "13", "5", "/", "+"]
→ 6
▸ tokens = ["10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+"]
→ 22
Progressive Hints
Hint 1 · Nudge
Operators act on the two most recent values you pushed.
Hint 2 · Plan
Push integer tokens onto a stack. On an operator, pop the two most recent values, apply the operator, and push the result. Keep the order straight for subtraction and division: the first value popped is b, the second is a, so compute a op b. Division truncates toward zero.
Hint 3 · Approach
stack = []. For each token: if it's a number, push it; else pop b, pop a, push a op b using the token's operator. Return the single value left on the stack.
Output
// Run your code to see the output here.