class Solution {
public:
int evalRPN(vector<string>& tokens) {
stack<int> num;
int size=tokens.size();
for(int i =0;i<size;++i){
string& token = tokens[i];
if(token.size()>1||isdigit(*token.c_str())){
num.push(atoi(token.c_str()));
}else{
int num2=num.top();
num.pop();
int num1=num.top();
num.pop();
switch (token[0])
{
case '+':
num.push(num1+num2);
break;
case '*':
num.push(num1*num2);
break;
case '-':
num.push(num1-num2);
break;
case '/':
num.push(num1/num2);
break;
}
}
}
return num.top();
}
};