101
0/304
Loading content...
A cinema operations system stores seat availability snapshots in a table.
Table: Cinema
Task: Return every maximum-length available segment.
Definition:
Output requirements:
Supported submission environments:
Cinema:
| seat_id | free |
|---------|------|
| 1 | 1 |
| 2 | 0 |
| 3 | 1 |
| 4 | 1 |
| 5 | 1 |[
{"first_seat_id": 3, "last_seat_id": 5, "consecutive_seats_len": 3}
]The free runs are [1] and [3,4,5]. The longest run length is 3, so only seats 3..5 are returned.
Cinema:
| seat_id | free |
|---------|------|
| 10 | 1 |
| 11 | 1 |
| 12 | 0 |
| 13 | 1 |
| 14 | 1 |[
{"first_seat_id": 10, "last_seat_id": 11, "consecutive_seats_len": 2},
{"first_seat_id": 13, "last_seat_id": 14, "consecutive_seats_len": 2}
]Two longest runs tie at length 2, so both are included.
Cinema:
| seat_id | free |
|---------|------|
| 7 | 0 |
| 8 | 0 |
| 9 | 0 |[]No available seats exist, so no segment can be formed.
Constraints