K03

Maximum Adjacent Temperature Difference

Junior Level Candidate
Target Time: 15 - 20 Minutes
Type: NUMERIC

Problem Statement & Objective

A meteorological station records daily temperatures at the exact same hour across an entire month. The lead climatologist wants to identify the single most abrupt day-to-day weather transition. Given a list of consecutive daily temperature readings, return the MAXIMUM ABSOLUTE DIFFERENCE between any two CONSECUTIVE days. If fewer than 2 days are recorded, return 0.

Function Signature (Python)

max_adjacent_temp_difference(temperatures: list[int]) -> int

Input & Output Contract

Output Rule:Maximum non-negative integer absolute difference between two adjacent readings.

System Constraints

0 <= sicakliklar.length <= 10^5
-50 <= sicakliklar[i] <= 60

Example Execution Walkthrough

sicakliklar = [15, 22, 18, 30, 10]
differences: |22-15|=7, |18-22|=4, |30-18|=12, |10-30|=20
max difference = 20

Example Test Scenarios (3)

Example 1
Input:[[12,15,9,9,20]]
Expected Output:11
Example 2: Fluctuating Temperature
Input:[[20,25,10,30]]
Expected Output:20
Example 3: Negative Temperatures
Input:[[-5,-15,-2,-8]]
Expected Output:13
Loading Python Editor...
Input Parameters
[
  [
    12,
    15,
    9,
    9,
    20
  ]
]
Expected Output
11