Straightforward Python
It not stated in the question but you can assume there is not invalid operations, such as C when the points history is empty, it still passed.\n\n\nclass Soluti
It not stated in the question but you can assume there is not invalid operations, such as `C` when the points history is empty, it still passed.\n\n```\nclass Solution(object):\n    def calPoints(self, ops):\n        # Time: O(n)\n        # Space: O(n)\n        history = []\n        for op in ops:\n            if op == 'C':\n                history.pop()\n            elif op == 'D':\n                history.append(history[-1] * 2)\n            elif op == '+':\n                history.append(history[-1] + history[-2])\n            else:\n                history.append(int(op))\n        return sum(history)\n\n```
[]