Back to course home
0% completed
Solution: Longest Continuous Subarray
Problem Statement
Given an array of integers nums
and an integer limit
, find the length of the longest contiguous nonempty
subarray withinnums
, where the absolute difference between any two elements in this subarray does not exceed a specified limit
.
Examples

Example 1:
 Input: Array = [10, 1, 2, 4, 7], Limit = 5
 Expected Output: 3
 Justification: The longest subarray where the absolute difference between any two numbers is at most 5 is [1, 2, 4].

Example 2:
 Input: Array = [4, 8, 5, 1, 7, 9], Limit = 3
.....
.....
.....
Like the course? Get enrolled and start learning!