evaluate-reverse-polish-notation
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
java
java的stack中,s.pop()不仅会弹出栈顶元素,还会返回栈顶元素。
String转int
Integer.parseInt
Integer.valueof()返回的是Integer的对象。
Integer.valueof().intValue();返回的也是一个int的值。
1 | import java.util.Stack; |
C++
1 | class Solution { |