Description: Matching brackets (two)
Time Limit: 1000 ms | Memory Limit: 65535 KB
Difficulty: 6
Description
Give you a string, which contains only "(", ")", "[", "]" Four symbols, what you need to add at least the number of brackets to make these brackets match up.
Such as:
[] Is matched
([]) [] Is matched
((] Is a mismatch
([)] Is a mismatch
Enter
The first line enter a positive integer N, the number of test data sets (N <= 10)
Each test is only one line, is a string S, S contains only four characters mentioned above, the length does not exceed 100 S
Export
For each test data outputs a positive integer indicating the minimum number needed to add parentheses. Each test output per line
Sample Input
4
[]
([]) []
((]
([)] Sample Output
0
0
3
2
To Search:
File list (Check if you may need any files):
ProgramA.cpp