Unable to understand sample input output

https://codeforces.com/contest/1095/problem/E
6
(((())
Answer for this is 3 how?

Hey @Bhawna
You have to give the count of indexes swapping which will make them balanced

For this (((())
U can swap 1,2,3 indexed braket
()(())
(()())
((()))
So hence answer is 3

Can u explain how to solve this question in simple words?I am not getting by reading editorial

Hey @Bhawna
Sorry for delay

In this problem, we have to calculate the number (count) of positions such that if we change the type of the bracket at this position then the obtained bracket sequence will become balanced.

We create prefixbalance array where ‘(’ we add +1 and ‘)’ we add -1
Similar;y we also create suffix balance array from reverse

We also create prefixcan and suffixcan which will store if prefix or suffix till ith can be prefix or suffic of balance exprn i.e they have to be valid.
prefixcan[i]=prefixcan[i-1]&&(prefixbal[i]>=0) If prefixbal[i] is negative then that means closing brackets are more than opening

Now if we have these arrays, let’s iterate over all positions in the initial bracket sequence. If we now at the position ii then let’s do the following things: firstly, if prefCan[i]=false or sufCan[i]=false then skip this position .
Otherwise, if the current bracket is opening then we have to increase the answer if prefBal[i−1]>0 and prefBal[i−1]-1+sufBal[i+1]=0 (only in this case the bracket sequence will become balanced do dry run for same).
And if the current bracket is closing then we have to increase the answer if prefBal[i−1]>0 and
prefBal[i−1]+1−sufBal[i+1]=0

( ( ) ( ) )
1 2 1 2 1 0 prefix bal
1 1 1 1 1 1 prefixcan

0 1 2 1 2 1 suffix bal
1 1 1 1 1 1 suffixcan