/*
* @lc app=leetcode.cn id=2011 lang=typescript
*
* [2011] 执行操作后的变量值
*/
// @lc code=start
function finalValueAfterOperations(operations: string[]): number {}
// @lc code=end
function finalValueAfterOperations(operations: string[]): number {
let res = 0
for (let s of operations) {
if (s[0] === '+' || s[1] === '+') res++
else res--
}
return res
}
test.each([
{ input: { operations: ['--X', 'X++', 'X++'] }, output: 1 },
{ input: { operations: ['++X', '++X', 'X++'] }, output: 3 },
{ input: { operations: ['X++', '++X', '--X', 'X--'] }, output: 0 },
])('input: operations = $input.operations', ({ input: { operations }, output }) => {
expect(finalValueAfterOperations(operations)).toEqual(output)
})