简单的模拟
class Solution {
public:
int finalValueAfterOperations(vector<string>& operations) {
int ans = 0;
for (auto str : operations) {
if (str[0] == 'X') {
if (str[1] == '+') ans += 1;
else ans -= 1;
} else if (str[0] == '+') {
ans += 1;
} else {
ans -= 1;
}
}
return ans;
}
};
标签:operations,int,每日,20221223,else,str,ans
From: https://www.cnblogs.com/zhanghanLeo/p/17000039.html