Statement
Given an arithmetic expression in a tokens, your task is to evaluate and return the value of the given expression.
Points to consider:
-
Valid operators are
+,-,*, and/. -
Each operand can be an integer or another expression.
-
The division between two integers should truncate toward zero.
The given Reverse Polish Notation expression is guaranteed to be valid. This ensures that the expression always evaluates to a result and that there are no division-by-zero operations.
Constraints:
-
tokens.length -
tokens[i]is either an operator (+,-,*, or/) or an integer in the range .