Longest Subarray With Absolute Diff ≤ Limit

Medium · Queue & Deque · about 25 minutes

Asked at Uber, Google, Amazon, Meta.

Find the longest non-empty contiguous slice of nums whose largest and smallest values differ by no more than limit, and return its length.

Related guides