Given a string s consisting only of the characters '[' and ']', you may perform swaps of any two characters in s. Return the minimum number of swaps required to transform s into a balanced bracket string.
A string is balanced if it can be read from left to right such that, at every position, the number of '[' seen so far is at least the number of ']' seen so far, and the total counts of '[' and ']' are equal.
Constraints:
n == s.length
n
n is even
s[i] is either '[' or ']'
The number of '[' in s equals n / 2, and the number of ']' in s equals n / 2
Given a string s consisting only of the characters '[' and ']', you may perform swaps of any two characters in s. Return the minimum number of swaps required to transform s into a balanced bracket string.
A string is balanced if it can be read from left to right such that, at every position, the number of '[' seen so far is at least the number of ']' seen so far, and the total counts of '[' and ']' are equal.
Constraints:
n == s.length
n
n is even
s[i] is either '[' or ']'
The number of '[' in s equals n / 2, and the number of ']' in s equals n / 2