[2011. 执行操作后的变量值] (https://leetcode.cn/problems/final-value-of-variable-after-performing-operations/description/)
class Solution {
public int finalValueAfterOperations(String[] operations) {
int res = 0;
for (String operation : operations) {
switch (operation) {
case "--X" :
case "X--" :
res --; break;
case "X++" :
case "++X" :
res ++; break;
default: break;
}
}
return res;
}
}
标签:case,operations,--,res,变量值,break,执行,2011
From: https://www.cnblogs.com/eiffelzero/p/17001239.html