Logo
Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Longest Continuous Subarray (medium)

Problem Statement

Find the length of the longest contiguous subarray within an array of integers, where the absolute difference between any two elements in this subarray does not exceed a specified limit. The challenge lies in ensuring the subarray is continuous and the range (difference between the maximum and minimum element in the subarray) fits within the given threshold.

Examples

  1. Example 1:
    • Input: Array = [10, 1, 2, 4, 7], Limit = 5
    • Expected Output: 3

.....

.....

.....

Like the course? Get enrolled and start learning!