Given a string containing only ‘(’ and ‘)’, you have to handle 2 types of operations on it:
update x,y: flip all parenthesis in the string lying between x to y (both inclusive) (all occurrences of ‘(’ are replaced with ‘)’ and all occurences of ‘)’ are replaced with ‘(’ ).
query x: find the longest contiguous correct bracket sequence starting from position x.
The length of the string is N , and you have to handle Q operations.
A Correct Bracket Sequence (CBS) is a sequence that can be obtained through following rules:
An empty string is a CBS.
If A is a CBS, then B = (A) is also a CBS.
If A and B are CBS, then C = AB is also a CBS.
N <= 10^6 , Q <= 10^6 ( or maybe Test cases <= 10 and N <= 10^5 , Q <= 10^5 )