Baseball Game LeetCode solution in Python
1class Solution:2def calPoints(self, ops: List[str]) -> int:3temp = []4for i in ops:5if i != "C" and i != "D" and i != "+":6temp.append(int(i))7elif i == "C":8temp.remove(temp[len(temp) - 1])9elif i == "D":10temp.append(2 * temp[len(temp) - 1])11elif i == "+":12temp.append(temp[len(temp) - 1] + temp[len(temp) - 2])1314return sum(temp)