Evaluate Reverse Polish Notation
https://leetcode.com/problems/evaluate-reverse-polish-notation/description/
Evaluate the value of an arithmetic expression inReverse Polish Notation.
Valid operators are
+
,-
,*
,/
. Each operand may be an integer or another expression.
Thoughts
stack的又一经典应用。
Code
Analysis
做题耗时: 8min
Errors:
op1和op2顺序弄反了
-和负数没分清
时空复杂度都是O(n).
Last updated
Was this helpful?