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 |
반응형
'python-algorithm' 카테고리의 다른 글
Leetcode 1588. Sum of All Odd Length Subarrays (0) | 2021.08.31 |
---|---|
Leetcode 1720. Decode XORed Array (0) | 2021.08.31 |
Leetcode 1441 Build an Array with Stack Operations (0) | 2021.08.30 |
백준 3135 라디오 (0) | 2021.08.30 |
백준 22993 서든어택 3 (0) | 2021.08.26 |
댓글