Back to problems Sign in to unlock
Leetcode
Medium
Arrays
Hash Maps
Strings
Rising Temperature
Return the ids of days where the temperature is higher than the previous day.
Acceptance 100%
Problem Statement
Rising Temperature
You are given a weather table with daily temperature readings. For each day, find the row(s) whose temperature is strictly higher than the temperature recorded on the previous calendar day.
Return the identifiers of those days.
The result can be returned in any order unless the platform specifies otherwise.
Input Format
You are given a table Weather with columns:
id— unique row idrecordDate— date of the readingtemperature— daily temperature
Dates are unique in the table.
Output Format
Return a table with a single column:
id— the ids of the rows wheretemperature > previous day's temperature
Constraints
recordDatevalues are unique.- Compare each row only with the immediately previous calendar day.
- Only rows with a valid previous day record can qualify.
Examples
Sample cases returned by the problem API.
Example 1
Input
Weather table | id | recordDate | temperature | |----|------------|-------------| | 1 | 2015-01-01 | 10 | | 2 | 2015-01-02 | 25 | | 3 | 2015-01-03 | 20 | | 4 | 2015-01-04 | 30 |
Output
| id | |----| | 2 | | 4 |
Explanation
- 2015-01-02 is warmer than 2015-01-01.
- 2015-01-04 is warmer than 2015-01-03.
- 2015-01-03 is not warmer than 2015-01-02.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.
Guided hints
Editorial and discussion links
Concept map and variants
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.