Final Value of Variable After Performing Operations LeetCode solution in Python

1
# Runtime: 111 ms (Top 13.83%) | Memory: 14 MB (Top 12.56%)
2
class Solution:
3
def finalValueAfterOperations(self, operations: List[str]) -> int:
4
x = 0
5
for o in operations:
6
if "+" in o:
7
x += 1
8
else:
9
x -= 1
10
return x

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0