leetle

Daily challenge for 2026-07-26

572. Maximum Span of Close Temperatures

Given a sorted list of daily temperatures temps and an integer limit, find the maximum span of days (defined as the index difference j - i) between any two days i and j (where j >= i) such that the temperature difference temps[j] - temps[i] is at most limit.

Example:
Input: temps = [10, 12, 15, 18, 20, 25], limit = 6
Output: 2
Explanation: The maximum span is between index 0 (10) and index 2 (15) with a difference of 5 (<= 6), or index 1 (12) and index 3 (18) with a difference of 6 (<= 6). Both spans have a length of 3 - 1 = 2 or 2 - 0 = 2.

Run this challenge interactively in Python or JavaScript when the app loads.