150.|150. Evaluate Reverse Polish Notation
import operator
class Solution(object):
def evalRPN(self, tokens):
"""
:type tokens: List[str]
:rtype: int
"""
stack=[]
operators={"+":operator.add,"-":operator.sub,"*":operator.mul,"/":operator.div}
for item in tokens:
if item not in operators:
stack.append(int(item))
else:
b,a=stack.pop(),stack.pop()
stack.append(int(operators[item](a*1.0,b)))
return stack.pop()
推荐阅读
- CTF|reverse方向入门过程
- frp reverse proxy
- Python 中的反转字符串(reversed()切片等)
- C语言 创建一个数组实现函数initemptyreverse
- In App Purchase产品ID是否必须以Reverse-DNS开头()
- ?: (urls.W005) URL namespace '你的app_name' isn't unique. You may not be able to reverse a
- LINQ排序运算符(Order By, then By, Reverse)