Find the Longest Balanced Substring of a Binary String
Track the current run of zeros and the ones that follow it; each one closes a balanced candidate of length 2 * min(zeros, ones).
Track the current run of zeros and the ones that follow it; each one closes a balanced candidate of length 2 * min(zeros, ones).