bits where every element is either 0 or 1. Find the longest stretch of consecutive ones and return its length.
If the array contains no ones, return 0.bits=[0, 1, 1, 0, 1, 1, 1, 1, 0] → 4
There is a run of two ones and a run of four; the longest is 4.
bits=[0, 0, 0] → 0
There are no ones at all, so the answer is 0.
bits=[1, 0, 1] → 1
len(bits) ≤ 10⁵bits[i] is 0 or 1bits=[0, 1, 1, 0, 1, 1, 1, 1, 0]
4
Run checks the first 3 tests in your browser. Submit checks all 100 tests on the server, hidden ones included.