时间轴

2025-10-20

init


题目:

重拳出击!👊👊👊

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <vector>
#include <string>
using std::vector;
using std::string;

class Solution {
public:
int finalValueAfterOperations(vector<string> &operations)
{
int res = 0;
int n = operations.size();
int i;
for (i = 0; i < n; i++) {
if (operations[i].compare("++X") == 0 ||
operations[i].compare("X++") == 0) {
res++;
} else if (operations[i].compare("--X") ||
operations[i].compare("X--")) {
res--;
}
}
return res;
}
};