Evaluate Reverse Polish Notation (improve)

来源:互联网 发布:js 将变量替换成图片 编辑:程序博客网 时间:2024/06/08 05:55

Evaluate the value of an arithmetic expression in Reverse Polish Notation.

Valid operators are +-*/. Each operand may be an integer or another expression.

Some examples:

  ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9  ["4", "13", "5", "/", "+"] -> (4 + (13 / 5)) -> 6

while, why did not I think of using stack in the first place?

Here is the improvement!


0 0
原创粉丝点击