Given a string A consisting only of '(' and ')'.
You need to find minimum number of bracket reversals needed to make the expression balanced, if it not possible to make string balanced then return -1.
1 <= |A| <= 105
First argument is an string A.
Return a single integer denoting the minimum number of bracket reversals required to make the expression balanced, if it not possible to make string balanced then return -1.
A = "()"
A = "((("
We need to change ')' to '(' and '(' to ')' so that the expression becomes balanced, the balanced expression is '()'
It is not possible to make the string balanced by any number of bracket reversals.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.