shlogg · Early preview
Md Ariful Haque @mah-shamim

Longest Subarray With Absolute Diff Less Than Limit

Find longest subarray with abs diff <= limit: use 2 queues (min & max) to track elements. Slide window when diff > limit. Example: nums = [8,2,4,7], limit = 4 returns 2.

1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit
Medium
Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray is less than or equal to limit.
Example 1:

Input: nums = [8,2,4,7], limit = 4
Output: 2
Explanation: All subarrays are:


  [8] with maximum absolute diff |8-8| = 0 <= 4.
  [8,2] with maximum absolute diff |8-2| = 6 > 4.
  [8,2,4] with maximum absolute diff |8-2| = 6 > 4.
  [8,2,4,7] with maximum absolute diff |8-2| = 6 > 4.
  [2...