Skip to content

Commit 35fd1cd

Browse files
committed
initial commit: 603 added
0 parents  commit 35fd1cd

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
PDF/
2+
*.docx
3+
Challenging Problems on LeetCode.txt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
----Solution to LeetCode Database question 603: Consecutive Available Seats
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
### 603. Consecutive Available Seats
2+
3+
Table: cinema
4+
5+
```markdown
6+
+-------------+------+
7+
| Column Name | Type |
8+
| seat_id | int |
9+
+-------------+------+
10+
seat_id is an auto-increment primary key column for this table.
11+
Each row of this table indicates whether the ith seat is free or not. 1 means free while 0 means occupied.
12+
```
13+
14+
Write an SQL query to report all the consecutive available seats in the cinema.
15+
16+
Return the result table ordered by `seat_id` in ascending order.
17+
18+
The test cases are generated so that more than two seats are consecutively available.
19+
20+
The query result format is in the following example.
21+
22+
**Example 1:**
23+
24+
```markdown
25+
Cinema table:
26+
+---------+------+
27+
| seat_id | free |
28+
+---------+------+
29+
| 1 | 1 |
30+
| 2 | 0 |
31+
| 3 | 1 |
32+
| 4 | 1 |
33+
| 5 | 1 |
34+
+---------+------+
35+
36+
output:
37+
+---------+
38+
| seat_id |
39+
+---------+
40+
| 3 |
41+
| 4 |
42+
| 5 |
43+
+---------+
44+
```

0 commit comments

Comments
 (0)