Stack C++ Solution | Easy to Understand
\nclass Solution {\npublic:\n    int calPoints(vector<string>& ops) {\n        stack<int> nums;\n        for(int i=0;i<ops.size();i++){\n            if(ops[i]==
```\nclass Solution {\npublic:\n    int calPoints(vector<string>& ops) {\n        stack<int> nums;\n        for(int i=0;i<ops.size();i++){\n            if(ops[i]=="+"){\n                int ans=0;\n                ans+=nums.top();\n                int store=nums.top();\n                nums.pop();\n                ans+=nums.top();\n                int store2=nums.top();\n                nums.push(store);\n                nums.push(ans);\n            }\n            else if(ops[i]=="C"){\n                nums.pop();\n            }\n            else if(ops[i]=="D"){\n                int ans=0;\n                int val=nums.top();\n                ans=2*val;\n                nums.push(ans);\n            }\n            else{\n                nums.push(stoi(ops[i]));\n            }\n        }\n        int ans=0;\n        while(!nums.empty()){\n            ans+=nums.top();\n            nums.pop();\n        }\n        return ans;\n    }\n};\n```
['Stack', 'C']