Search⌘ K
AI Features

Solution: Longest Subarray With Diff At Most Limit

Solution: Longest Subarray With Diff At Most Limit asks you to return the length of the longest non-empty contiguous subarray where the maximum and minimum values differ by no more than the given limit.

Statement

Given an integer array nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements within that subarray is less than or equal to limit.

Constraints:

  • 1≤1 \leq nums.length ...