flips: 1 for heads, 0 for tails.
Find the longest contiguous run of flips with the same number of heads and tails, and return its length. If there is no such run, return 0.flips=[1, 1, 0, 1, 0, 0, 1, 1] → 6
The first six flips [1, 1, 0, 1, 0, 0] have three heads and three tails. No longer stretch is balanced.
flips=[0, 0, 0] → 0
Only tails came up, so there is no balanced stretch and the answer is 0.
flips=[1, 0, 0, 1] → 4
flips[i] is 0 or 1flips=[1, 1, 0, 1, 0, 0, 1, 1]
6
Run checks the first 3 tests in your browser. Submit checks all 114 tests on the server, hidden ones included.