#K5551. Maximum Mood Score
Maximum Mood Score
Maximum Mood Score
In this problem, you are given test cases. For each test case, you are provided with an integer representing the length of a sequence and a string of length consisting solely of the characters '+' and '-'. The mood score starts at 0 and is updated as you traverse the sequence: you add 1 for a '+' and subtract 1 for a '-'. Your task is to determine the maximum mood score achieved at any point during the sequence processing. Formally, define the mood score as follows:
$$M_i = M_{i-1} + \begin{cases} +1 & \text{if } s_i = '+' \\ -1 & \text{if } s_i = '-' \end{cases} $$You need to output the maximum value among for each test case.
inputFormat
The input is read from standard input (stdin) and is in the following format:
- The first line contains a single integer , the number of test cases.
- For each test case, there are two lines:
- The first line contains an integer , the length of the sequence.
- The second line contains a string of length consisting solely of the characters '+' and '-'.
outputFormat
For each test case, output a single integer on a new line representing the maximum mood score achieved during the sequence.## sample
2
5
++-+-
6
+-+++-
2
3
</p>