easy +10 pts

Consecutive available seats

Find the maximum number of consecutive available seats in a row.

You are given a list of integers `seats` where each element is either `0` (available) or `1` (occupied). Write a function `max_consecutive_available(seats: list[int]) -> int` that returns the maximum number of consecutive `0`s appears in the list. If there are no available seats, return `0`. The list may be empty; if empty, return `0`.

Constraints

0 <= len(seats) <= 10^5, elements are exactly 0 or 1. Time complexity O(n), space O(1).

Example

>>> max_consecutive_available([0, 0, 1, 0, 0, 0, 1])
3
>>> max_consecutive_available([1, 1, 1])
0
>>> max_consecutive_available([])
0
>>> max_consecutive_available([0])
1
10 points ~15 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Keep a running count of consecutive zeros you have seen so far.
Reset the count whenever you see a 1.
After each element, update the answer with the current count.
An empty list or all ones results in 0.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.