python-algorithm
leetcode 2011. Final Value of Variable After Performing Operations
무적김두칠
2022. 3. 7. 10:34
1
2
3
4
5
6
7
|
class Solution:
def finalValueAfterOperations(self, operations: List[str]) -> int:
start=0
for i in operations:
if '--' in i : start-=1
elif '++' in i : start+=1
return start
|
cs |
처음에는 prefix, suffix 구현인줄알았는데 아니네요 단순 사칙연산
반응형