python-algorithm
Leetcode 682. Baseball Game
무적김두칠
2021. 8. 30. 15:50
1
2
3
4
5
6
7
8
9
|
class Solution:
def calPoints(self, ops: List[str]) -> int:
tmp=[]
for i in ops:
if i=='C': tmp.pop()
elif i=='D':tmp.append (tmp[-1]*2)
elif i=="+":tmp.append(tmp[-1]+tmp[-2])
else : tmp.append(int(i))
return (sum(tmp))
|
cs |
반응형