//url:https://leetcode.com/problems/baseball-game/description/
class Solution {
public:
int calPoints(vector& ops) {
int result[1000];
int index=0;
int size=ops.size();
for(int i=0;i0)
index--;
}
else if("D"==ops[i])
{
if(index>0){
result[index]=result[index-1]*2;
index++;
}
}
else if("+"==ops[i])
{
if(index>=1){
result[index]=result[index-1]+result[index-2];
}else if(index>0){
result[index]=result[index-1];
}
index++;
}
else
{
result[index]=atoi(ops[i].c_str());
index++;
}
}
int sum=0;
for(int i=0;i