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)) -> 6Bug free. Could done better if we add more error handling (instead of checking +-*/, we could have more invalid inputs)
Hi,
ReplyDeleteWhat will be the result when the Final thing is out of bounds ? like 3/0 = Infinity(>Integer.MAX_VALUE);
Thanks,
Guru