forked from shuboc/LeetCode-2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Time: O(n^3) | ||
# Space: O(n^3) | ||
|
||
SELECT DISTINCT s1.* | ||
FROM stadium AS s1, stadium AS s2, stadium AS s3 | ||
WHERE s1.people >= 100 AND s2.people >= 100 AND s3.people >= 100 | ||
AND | ||
( | ||
(s2.id = s1.id + 1 AND s3.id = s2.id + 1 AND s3.id = s1.id + 2) -- s1, s2, s3 | ||
OR | ||
(s1.id = s2.id + 1 AND s3.id = s1.id + 1 AND s3.id = s2.id + 2) -- s2, s1, s3 | ||
OR | ||
(s3.id = s2.id + 1 AND s1.id = s3.id + 1 AND s1.id = s2.id + 2) -- s2, s3, s1 | ||
) | ||
ORDER BY s1.id | ||
; |