✅Easy C++ solution using Stack with explanations!
If you\u2019re interested in coding you can join my Discord Server, link in the comment section. Also if you find any mistakes please let me know. Thank you!\u2
> **If you\u2019re interested in coding you can join my Discord Server, link in the comment section. Also if you find any mistakes please let me know. Thank you!\u2764\uFE0F**\n> \n\n---\n\n## Explanation:\n\n### Solution 01\n\n- Here we are solving the problem using ***Stack,*** as it follows last in first out ***LIFO.***\n- There are 4possible cases:\n    1. `if(ops[i] == "+")` we have to store to 2 elements in 2 variables & push them including adding both and push them.\n    2. `if(ops[i] == "C")` we need to pop the last inserted element.\n    3. `if(ops[i] == "D")` next element will be double of last element, push that to stack.\n    4. Else there will be an integer, so push it directly to our stack \n- Add all the stack element to ans & return it.\n- **Time complexity:** O(n).\n\n---\n\n## Code:\n\n```cpp\n//Solution 01:\nclass Solution {\npublic:\n    int calPoints(vector<string>& ops) {\n        int ans = 0;\n        stack<int> st;\n        \n        for(int i=0; i<ops.size(); i++){\n            if(ops[i] == "+"){\n                int x = st.top();\n                st.pop();\n                int y = st.top();\n                st.pop();\n                \n                st.push(y);\n                st.push(x);\n                st.push(x+y);\n            }\n            else if(ops[i] == "C"){\n                st.pop();\n            }\n            else if(ops[i] == "D"){\n                st.push(2*st.top());\n            }\n            else{\n                int x = stoi(ops[i]);\n                st.push(x);\n            }\n        }\n        while(!st.empty()){\n            ans += st.top();\n            st.pop();\n        }\n        return ans;\n    }\n};\n```\n\n---\n\n> **Please upvote this solution on Leetcode:**\n>
['Stack', 'C', 'C++']