Easy solution that doesn't use stack
Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition here is to use a stack. But we can actually use a vector because it suppo
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition here is to use a stack. But we can actually use a vector because it supports pop_back and push_back operations. Most importantly, a vector can enable us to calculate the case "+" easily: we don\'t need to pop twice. Instead, we can simply index the last and second elements in the vector and sum them up. \n\nAlso, to optimize time complexity, we can keep a running sum instead of writing a for loop to summing up all elements in vector/stack eventually.\n \n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(n)\n# Code\n```\nclass Solution {\npublic:\n    int calPoints(vector<string>& operations) {\n    vector<int> record;\n    int sum = 0;\n    for (auto o : operations) {\n        if (o == "+") {\n            int add1 = record.back();\n            int add2 = record[record.size() - 2];\n            int sumOfTwo = add1 + add2;\n            record.push_back(sumOfTwo);\n            sum += sumOfTwo;\n        } else if (o == "D") {\n            int doublePrev = 2 * record.back();\n            record.push_back(doublePrev);\n            sum += doublePrev;\n        } else if (o == "C") { \n            int subtract = record.back();\n            record.pop_back();\n            sum -= subtract;\n        } else {\n            int toadd = stoi(o);\n            record.push_back(toadd);\n            sum += toadd;\n        }\n    }\n    return sum;\n}\n\n};\n```
['Array', 'C++']