Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 6d90c23

Browse files
authored
rising-temperature
1 parent e8444d5 commit 6d90c23

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

MySQL/rising-temperature.sql

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Time: O(n^2)
22
# Space: O(n)
33

4-
SELECT wt1.Id
5-
FROM Weather wt1, Weather wt2
6-
WHERE wt1.Temperature > wt2.Temperature AND
7-
TO_DAYS(wt1.DATE)-TO_DAYS(wt2.DATE)=1;
4+
SELECT t.id FROM Weather t
5+
JOIN Weather m ON t.recordDate = DATE_ADD(m.recordDate, interval 1 day)
6+
WHERE t.temperature > m.temperature
87

0 commit comments

Comments
 (0)