2011. Final Value of Variable After Performing Operations
https://leetcode.com/problems/final-value-of-variable-after-performing-operations
Description
There is a programming language with only four operations and one variable X
:
++X
andX++
increments the value of the variableX
by1
.--X
andX--
decrements the value of the variableX
by1
.
Initially, the value of X
is 0
.
Given an array of strings operations
containing a list of operations, return the final value of X
after performing all the operations.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= operations.length <= 100
operations[i]
will be either"++X"
,"X++"
,"--X"
, or"X--"
.
ac
Previous2010. The Number of Seniors and Juniors to Join the Company IINext2012. Sum of Beauty in the Array
Last updated