classSolution { public: intevalRPN(vector<string>& tokens){ vector<int> nums; for(int i = 0; i < tokens.size(); i++){ string s = tokens[i]; if(s.size() == 1 && (s == "+" || s == "-" || s == "*" || s == "/")){ int a = nums.back(); nums.pop_back(); int b = nums.back(); nums.pop_back(); int re; switch(s[0]){ case'+': re = a + b; break; case'-': re = b - a; break; case'*': re = b * a; break; case'/': re = b / a; break; } nums.push_back(re); } else{ nums.push_back(stoi(s)); } } return nums[0]; } };