##Pyth, 15 13 bytes
Pyth, 15 13 bytes
-2 bytes by @Maltysen
eSm-F/Ld`Y._z
Counts the difference between the cumulative counts of [
and ]
, and takes the maximum. Y
is the empty array, and its string representation (`
) is conveniently []
.
Try it here.