Final Value of Variable After Performing Operations LeetCode solution in Java

1
class Solution {
2
public int finalValueAfterOperations(String[] operations) {
3
int val = 0;
4
for (int i = 0; i < operations.length; i++) {
5
if (operations[i].charAt(1) == '+') val++;
6
else val--;
7
}
8
return val;
9
}
10
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0