Tap here to switch tabs
Problem
Ask
Submissions

Problem: Longest Subarray With Diff At Most Limit

med
30 min
Explore how to apply the sliding window pattern to find the longest subarray in an integer array where the absolute difference between any two elements does not exceed a given limit. This lesson helps you understand constraints, approach, and implementation to efficiently solve related coding interview problems.

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:

  • 11 \leq nums.length 105\leq 10^5

  • 11 \leq nums[i] 109\leq 10^9

  • 00 \leq limit 109\leq 10^9

Tap here to switch tabs
Problem
Ask
Submissions

Problem: Longest Subarray With Diff At Most Limit

med
30 min
Explore how to apply the sliding window pattern to find the longest subarray in an integer array where the absolute difference between any two elements does not exceed a given limit. This lesson helps you understand constraints, approach, and implementation to efficiently solve related coding interview problems.

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:

  • 11 \leq nums.length 105\leq 10^5

  • 11 \leq nums[i] 109\leq 10^9

  • 00 \leq limit 109\leq 10^9