From cf3e8b4651efb1e41d1c5984d08f80fffd79422d Mon Sep 17 00:00:00 2001 From: Deven <63876261+devenperez@users.noreply.github.com> Date: Sat, 14 Jan 2023 20:24:11 -0500 Subject: [PATCH] Time: 57 ms (66.84%), Space: 13.8 MB (52.98%) - LeetHub --- ...l-value-of-variable-after-performing-operations.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 2011-final-value-of-variable-after-performing-operations/2011-final-value-of-variable-after-performing-operations.py diff --git a/2011-final-value-of-variable-after-performing-operations/2011-final-value-of-variable-after-performing-operations.py b/2011-final-value-of-variable-after-performing-operations/2011-final-value-of-variable-after-performing-operations.py new file mode 100644 index 0000000..89d0aa1 --- /dev/null +++ b/2011-final-value-of-variable-after-performing-operations/2011-final-value-of-variable-after-performing-operations.py @@ -0,0 +1,11 @@ +class Solution: + def finalValueAfterOperations(self, operations: List[str]) -> int: + value = 0 + + for op in operations: + if "+" in [op[0], op[-1]]: + value += 1 + else: + value -= 1 + + return value \ No newline at end of file