


Consider booking queries to be ["+1A", "+3E", "-1A", "+4F", "+1A", "-3E"]
+1A: Room A on the 1st floor is booked and you collected 1 coin.
+3E: Room E on the 3rd floor is booked and you collected 1 coin.
-1A: Room A on the 1st floor is freed.
+4F: Room F on the 4th floor is booked and you collected 1 coin.
+1A: Room A on the 1st floor is booked and you collected 1 coin.
-3E: Room E on the 3rd floor is freed.
So you collected 4 coins.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains an integer ‘N’ representing the number of queries.
The second line of each test case contains N space-separated strings representing booking queries.
For each test case, return an integer denoting the count of coins you collected.
You don’t need to print anything; it has already been taken care of. Just implement the given function.
1 <= T <= 10^2
0 <= N <= 6*10^2
|query.length| = 3
Time Limit: 1 sec
The approach is simple just count the number of room booked queries.
All we need to do is just traverse over each query string and check if the first character is a ‘+’. If it is a ‘+’ just increase the number of coins collected as the list describes a correct sequence of bookings, so each booking is valid.
The algorithm for the same is as follows: