class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param tokens string字符串vector 
     * @return int整型
     */
    int evalRPN(vector<string>& tokens) {
        // write code here
        stack<int> st;
        for (auto& s: tokens) {
            if (s != "+" && s != "-" && s != "*" && s != "/") {
                st.push(stoi(s));
            } else {
                int num = st.top(); st.pop();
                if (s == "+") {
                    st.top() += num;
                } else if (s == "-") {
                    st.top() -= num;
                } else if (s == "*") {
                    st.top() *= num;
                } else {
                    st.top() /= num;
                }
            }
        }
        return st.top();
    }
};