readings. Count the non-empty stretches (runs of consecutive elements) that consist entirely of zeros.
Stretches at different positions count separately, even if they have the same length.readings=[0, 0, 0, 5, 0] → 7
The run of three zeros gives 3 + 2 + 1 = 6 stretches, and the lone zero at the end adds one more: 7 in total.
readings=[4, -1, 0, 0] → 3
The zeros sit together at the end: two stretches of length 1 and one of length 2.
readings=[7, 8] → 0
There are no zeros at all.
readings=[0, 0, 0, 5, 0]
7
Run checks the first 3 tests in your browser. Submit checks all 102 tests on the server, hidden ones included.