Trains the technique from
LeetCode 2348Number of Zero-Filled SubarraysThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A log holds the readings readings.
Return how many stretches of one or more neighbouring readings hold nothing but zeros.
Example 1
Three single zeros, two neighbouring pairs and the whole run come to six stretches.
Example 2
Each zero stands on its own, so only the two one-reading stretches count.
Example 3
The run of two zeros gives three stretches and the run of three gives six.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def zero_filled_subarray(readings: list[int]) -> int:public long zeroFilledSubarray(int[] readings)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.