⭐️  [ Kt, Js, Py3, Cpp ] 🥞  Stack Accumulation
Synopsis:\n\nUse a stack s to store previous rounds\' points.  Return the accumulated sum of what\'s leftover on the stack s after processing all operations ops
**Synopsis:**\n\nUse a stack `s` to store previous rounds\' points.  Return the accumulated sum of what\'s leftover on the stack `s` after processing all operations `ops`.\n\n---\n\n**Note:** there is a typo in this problem description.  The **Example 1 output should be 30**, ```(15 is NOT correct)```\n\nExample 1:\nInput: ["5","2","C","D","+"]\n~~Output: 15~~ \u274C\nOutput: 30 \u2705\n\n---\n\n*Kotlin*\n```\nclass Solution {\n    fun calPoints(ops: Array<String>): Int {\n        var s = Stack<Int>()\n        ops.forEach { op ->\n            when (op) {\n                "+"  -> s.push(s[s.lastIndex] + s[s.lastIndex - 1])\n                "D"  -> s.push(2 * s.last())\n                "C"  -> s.pop()\n                else -> s.push(op.toInt())\n            }\n        }\n        return s.sum()\n    }\n}\n```\n\n*Javascript*\n```\nlet calPoints = (ops, s = []) => {\n    for (op of ops) {\n        let n = s.length;\n        if (op == \'+\')\n            s.push(s[n - 2] + s[n - 1]);\n        else if (op == \'D\')\n            s.push(2 * s[n - 1]);\n        else if (op == \'C\')\n            s.pop();\n        else\n            s.push(+op);\n    }\n    return _.sum(s)\n};\n```\n\n*Python3*\n```\nclass Solution:\n    def calPoints(self, ops: List[str]) -> int:\n        s = []\n        for op in ops:\n            if op == "+":\n                s.append(s[-2] + s[-1])\n            elif op == "D":\n                s.append(2 * s[-1])\n            elif op == "C":\n                s.pop()\n            else:\n                s.append(int(op))\n        return sum(s)\n```\n\n*C++*\n```\nclass Solution {\npublic:\n    using VS = vector<string>;\n    using VI = vector<int>;\n    int calPoints(VS& ops, VI s = {}) {\n        for (auto& op: ops) {\n            int n = s.size();\n            if (op == "+")\n                s.push_back(s[n - 2] + s[n - 1]);\n            else if (op == "D")\n                s.push_back(2 * s[n - 1]);\n            else if (op == "C")\n                s.pop_back();\n            else\n                s.push_back(stoi(op));\n        }\n        return accumulate(s.begin(), s.end(), 0);\n    }\n};\n```
[]