Final Value of Variable After Performing Operations (Leetcode 2011)

Problem Link: https://leetcode.com/problems/final-value-of-variable-after-performing-operations/

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

Last updated