@@ -0,0 +1,823 @@
+import unittest%0A%0A%0A# O(n)%0Aclass Solution(object):%0A    def calPoints(self, ops):%0A        %22%22%22%0A        :type ops: List%5Bstr%5D%0A        :rtype: int%0A        %22%22%22%0A        stack = %5B%5D%0A        for op in ops:%0A            if op == '+':%0A                stack.append(stack%5B-1%5D + stack%5B-2%5D)%0A            elif op == 'D':%0A                stack.append(stack%5B-1%5D * 2)%0A            elif op == 'C':%0A                stack.pop()%0A            else:%0A                stack.append(int(op))%0A        return sum(stack)%0A%0A%0Aclass Test(unittest.TestCase):%0A    def test(self):%0A        self._test(%5B%225%22, %222%22, %22C%22, %22D%22, %22+%22%5D, 30)%0A        self._test(%5B%225%22, %22-2%22, %224%22, %22C%22, %22D%22, %229%22, %22+%22, %22+%22%5D, 27)%0A%0A    def _test(self, ops, expected):%0A        actual = Solution().calPoints(ops)%0A        self.assertEqual(actual, expected)%0A%0A%0Aif __name__ == '__main__':%0A    unittest.main()%0A

682. Baseball Game. O(n)