Longest Valid Substring

0

0 votes
Medium
Problem

Given a string S consisting of opening and closing parenthesis '(' and ')'. Find length of the longest valid parenthesis substring.

Input:
Each line has a string S of character '(' and ')' of length  N.

Constraints:
1 <= T <= 500
1 <= N <= 105

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?