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
思路:四则运算,利用stack。这也是IDG资本的一道笔试题。
class Solution {
public:
int strToInt(string str) {
int res = 0,j=1,i;
for(i=str.length()-1; i>=0&&s......
阅读全文