Given a string of brackets, the task is to find an index k which decides the number of opening brackets is equal to the number of closing brackets. The string must consist of only opening and closing brackets.
"(())))("
should return 4
since it splits the string into (())
and ))(
and the number of (
in the former is equal to the number of )
in the latter.
"))"
should return 2
since it splits the string into ))
which has no (
in it and empty string which has no )
in it.