You are given a table Cinema that contains information about cinema seats and their availability status.
Table: Cinema
| Column Name | Type |
|---|---|
| seat_id | int |
| free | bool |
seat_id is an auto-increment column for this table. Each row indicates whether the seat is available or occupied.
1means the seat is free (available)0means the seat is occupied
Task: Find all consecutive available seats in the cinema. Return the result ordered by seat_id in ascending order.
Note: The test cases guarantee that more than two seats are consecutively available.
Table Schema
| Column Name | Type | Description |
|---|---|---|
seat_id
PK
|
int | Auto-increment primary key representing seat number |
free
|
bool | 1 if seat is available, 0 if occupied |
Input & Output
| seat_id | free |
|---|---|
| 1 | 1 |
| 2 | 1 |
| 3 | 0 |
| 4 | 1 |
| 5 | 1 |
| seat_id |
|---|
| 1 |
| 2 |
| 4 |
| 5 |
Seats 1 and 2 are both free and consecutive. Seat 3 is occupied, so it breaks the sequence. Seats 4 and 5 are both free and consecutive. Therefore, all seats except seat 3 are part of consecutive available groups.
| seat_id | free |
|---|---|
| 1 | 0 |
| 2 | 1 |
| 3 | 1 |
| 4 | 1 |
| 5 | 0 |
| seat_id |
|---|
| 2 |
| 3 |
| 4 |
Seats 2, 3, and 4 form one continuous block of available seats. Seats 1 and 5 are occupied, so they don't appear in the result. All three consecutive seats (2, 3, 4) are returned.
| seat_id | free |
|---|---|
| 1 | 1 |
| 2 | 1 |
| 3 | 0 |
| 4 | 0 |
| 6 | 1 |
| 7 | 1 |
| 8 | 1 |
| seat_id |
|---|
| 1 |
| 2 |
| 6 |
| 7 |
| 8 |
Two separate groups of consecutive seats: seats 1-2 form one group, and seats 6-7-8 form another group. Seats 3 and 4 are occupied. Note that seat 5 is missing from the table, creating a gap between the groups.
Constraints
-
1 ≤ seat_id ≤ 50 -
freeis either0or1 - More than two seats are consecutively available