150. Evaluate Reverse Polish Notation
# Medium
Not hard if know the principle behind and coding as the process of human solving
Key idea: when see notation, compute the two numbers before it.
stack
is perfect to this problem
Solution:
traversal all elements of the list
if it's a number, push to stack
if it's a notation, pop two numbers and compute, then push back to stack
如果用python则不能用recursive来做,因为python不能传递reference,意味着函数的参数无法成为全局变量,而导致一直在变
Last updated