2011. Final Value of Variable After Performing Operations
There is a programming language with only?four?operations and?one?variable?X
:
++X
?and?X++
?increments?the value of the variable?X
?by?1
.--X
?and?X--
?decrements?the value of the variable?X
?by?1
.
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.
?
Two strings?word1
?and?word2
?are considered?almost equivalent?if the differences between the frequencies of each letter from?'a'
?to?'z'
?between?word1
?and?word2
?is?at most?3
.
Given two strings?word1
?and?word2
, each of length?n
, return?true
?if?word1
?and?word2
?are?almost equivalent, or?false
?otherwise.
The?frequency?of a letter?x
?is the number of times it occurs in the string.
Success
Details?
Runtime:?1 ms, faster than?83.93%?of?Java?online submissions for?Final Value of Variable After Performing Operations.
Memory Usage:?40.1 MB, less than?36.40%?of?Java?online submissions for?Final Value of Variable After Performing Operations.