Final Value of Variable After Performing Operations LeetCode solution in C++

1
class Solution {
2
public:
3
int finalValueAfterOperations(vector<string> &o, int c = 0) {
4
for (auto &i : o)
5
if (i == "++X" or i == "X++")
6
c++;
7
else
8
c--;
9
return c;
10
}
11
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0