tokens is an arithmetic expression in reverse Polish notation (the operator comes after its two operands): ["2", "1", "+", "3", "*"] means (2 + 1) * 3 = 9. Operators are +, -, * and /. Division truncates toward zero (7 / -2 = -3). Return the value.
Example 1
Input:
evaluate_rpn(['2', '1', '+', '3', '*'])
Output:
9
Example 2
Input:
evaluate_rpn(['4', '13', '5', '/', '+'])
Output:
6
1 <= len(tokens) <= 100000No results yet
Run your code to check it against the examples, or submit to run every test.