Easy
Final Value of Variable After Performing Operations — Python
Full explanation · Time O(n) · Space O(1)
# Time: O(n)
# Space: O(1)
class Solution(object):
def finalValueAfterOperations(self, operations):
"""
:type operations: List[str]
:rtype: int
"""
return sum(1 if '+' == op[1] else -1 for op in operations)