0% completed
Given an integer array nums
and an integer limit
, return the maximum length of a continuous subarray such that the absolute difference between any two elements in this subarray is less than or equal to limit
. The subarray must be non-empty.
Example 1:
[6, 7, 9]
or [7, 9, 10]
array. The absolute difference between any two elements in these subarrays is at most 3.Example 2:
Example 3:
[1, 5]
, [5, 9]
, [9, 13]
or [13, 14]
array. The absolute difference between any two elements in these subarrays is at most 4.Constraints:
Try solving this question here: