


1. You are not required to print the output explicitly, it has already been taken care of. Just implement the function and return the minimum number of parentheses required to make a string valid.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The next ‘T’ lines represent the ‘T’ test cases.
The first line of each test case contains a string "pattern".
For each test case, return the minimum number of parentheses.
1 <= T <= 50
1 <= N <= 10^4
Where ‘T’ is the total number of test cases, ‘N’ denotes the length of string "pattern".
Time limit: 1 second
The basic idea is that, store the count of ‘(‘ and ‘)’ and try to balance ‘(‘ and ‘)’.