Starting from X = 0, apply every operation in operations and return the final value of X.
X = 0
operations
X
++X and X++ both add 1; --X and X-- both subtract 1.
++X
X++
--X
X--
operations = ["--X","X++","X++"]
1
operations = ["++X","++X","X++"]
3
1 <= operations.length <= 100 Every operation is one of `++X`, `X++`, `--X`, `X--`.
Topics
Implement finalValue in the editor and return the answer — printing it is never graded.
finalValue
Problem 52 of 1146 in the arena