class Solution:
def evalRPN(self, tokens: List[str]) -> int:
stack = []
# op_map = {'+': add, '-': sub, '*': mul, '/': lambda x, y: int(x / y)}
for token in tokens:
if token in ['+', '-', '*', '/']:
a = stack.pop(-1)
b = stack.pop(-1)
if token == '+':
x = a + b
elif token == '-':
x = b - a
elif token == '*':
x = b * a
elif token == '/':
x = b / a
else:
raise ValueError
stack.append(int(x))
else:
stack.append(int(token))
return stack[-1]