Using stack || c++ || cpp|| two solutions || 100% faster
My first approach: simply converting the integer to string and back and forth\n\nclass Solution {\npublic:\n    int calPoints(vector<string>& ops) {\n        st
**My first approach**: simply converting the integer to string and back and forth\n```\nclass Solution {\npublic:\n    int calPoints(vector<string>& ops) {\n        stack<string> s;\n        for(auto x:ops)\n        {\n            if(x!="D"&&x!="C"&&x!="+")\n                s.push(x);\n            else if(x=="D")\n            {\n                int temp = 2*stoi(s.top());\n                    s.push(to_string(temp));\n            }\n            else if(x=="C")\n                s.pop();\n            else if(x=="+")\n            {\n                int temp1 = stoi(s.top());\n                s.pop();\n                int temp2=stoi(s.top());\n                s.push(to_string(temp1));\n                s.push(to_string(temp1+temp2));\n            }\n            \n        }\n        int sum=0;\n        while(!s.empty())\n        {\n            sum+=stoi(s.top());\n            s.pop();\n        }\n        return sum;\n    }\n};\n```\n\n**Optimized Solution** : Here is have taken the inpust in the stack as int which resulted in 100% time efficiency\n```\nclass Solution {\npublic:\n    int calPoints(vector<string>& ops) {\n        stack<int> s;\n        for(auto x:ops)\n        {\n            if(x!="D"&&x!="C"&&x!="+")\n                s.push(stoi(x));\n            else if(x=="D")\n            {\n                int temp = 2*s.top();\n                    s.push(temp);\n            }\n            else if(x=="C")\n                s.pop();\n            else if(x=="+")\n            {\n                int temp=s.top();\n                s.pop();\n                int temp2=s.top();\n                s.push(temp);\n                s.push(temp+temp2);\n            }\n            \n        }\n        int sum=0;\n        while(!s.empty())\n        {\n            sum+=s.top();\n            s.pop();\n        }\n        return sum;\n    }\n};\n```
[]