spots: 1 means a car is parked there, 0 means the spot is free. The rules require at least gap free spots between any two neighbouring cars.
Return True if the whole row follows the rule, and False otherwise.spots=[1, 0, 0, 1, 0, 0, 0, 1], gap=2 → True
There are 2 free spots between the first and second car and 3 between the second and third. Both gaps are at least 2.
spots=[0, 1, 0, 1, 0, 0], gap=2 → False
Only one free spot separates the two cars, and at least 2 are required.
spots=[0, 0, 1, 0], gap=4 → True
There is only one car, so there is nothing to keep a distance from.
len(spots) ≤ 10⁵gap ≤ len(spots)spots[i] is 0 or 1spots=[1, 0, 0, 1, 0, 0, 0, 1], gap=2
True
Run checks the first 3 tests in your browser. Submit checks all 107 tests on the server, hidden ones included.