17 lines
371 B
Go
17 lines
371 B
Go
// Package q2011 implements a solution for https://leetcode.com/problems/final-value-of-variable-after-performing-operations/
|
|
package q2011
|
|
|
|
func finalValueAfterOperations(operations []string) int {
|
|
x := 0
|
|
for i := range operations {
|
|
switch operations[i] {
|
|
case "X++", "++X":
|
|
x++
|
|
case "X--", "--X":
|
|
x--
|
|
}
|
|
}
|
|
return x
|
|
}
|
|
|
|
var _ = finalValueAfterOperations
|