Given a string S , of length N (contains parenthesis ) , and Q queries, in each query L and R be two indexes of string find the length of the longest balanced substring between L to R.
Ex : S = ( ( ) ) ( ) ( ) ( ( ( )
Q = 2
L = 1 , R = 4 answer = 4
L = 4 , R = 9 answer = 4
I solved this : “https://codeforces.com/contest/380/problem/C” [Subsequence] , but don’t know how to solve above ?
And If anyone find out same question above then please share , as I google and only find subsequence variant .