you give 0indexed string s length n the string consist exactly n 2 opening bracket n 2 closing bracket a string call balanced ifIt string orIt write AB A B balanced string orIt write C C balance stringyou swap bracket index number timesreturn minimum number swap s balanced Example 1input s output 1explanation you string balanced swap index 0 index 3the result string Example 2input s output 2explanation you follow string balanced Swap index 0 index 4 s Swap index 1 index 5 s the result string Example 3input s output 0explanation the string balance Constraintsn slength2 n 106n evensi the number opening bracket equal n 2 number closing bracket equal n 2