2011. Final Value of Variable After Performing Operations

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2011

class Solution:
    def finalValueAfterOperations(self, operations: List[str]) -> int:
        return sum(1 if s[1] == '+' else -1 for s in operations)