[LeetCode] 2011. Final Value of Variable After Performing Operations
Python
class Solution:
def finalValueAfterOperations(self, operations: List[str]) -> int:
answer = 0
for operation in operations:
if operation == '++X' or operation == 'X++':
answer += 1
elif operation == '--X' or operation == 'X--':
answer -= 1
return answer
댓글남기기