150. Evaluate Reverse Polish Notation

Practice Evaluate Reverse Polish Notation for free on NudgeCode: Medium, Stack pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Evaluate an arithmetic expression written in Reverse Polish Notation, where each operator comes after its two operands. tokens contains integers and the operators +, -, *, /.

Integer division truncates toward zero (-7 / 2 is -3). The expression is always valid and never divides by zero.

Example

tokens = ["4","13","5","/","+"]  ->  6   (4 + 13 / 5)

Constraints