Given a string S consisting of opening and closing parenthesis '(' and ')'. Find length of the longest valid parenthesis substring.
First line contains number of test cases T. Each test case have one line string S of character '(' and ')' of length N.
1 <= T <= 500
1 <= N <= 105
Testcase 1: Longest valid balanced parantheses is () and its length is 2.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.