Question bank › Two Pointers
Dsa Two Pointers Easy

The Clean Signal Segment

You are monitoring a data stream of signal values. A signal value is considered 'clean' if it falls within the inclusive range [L, R]. You can tolerate a segment of signal that contains at most K 'noisy' (not clean) values. Find the length of the longest contiguous segment that meets this criterion. Input Format: Line 1: Two integers L and R. Line 2: An integer K (max allowed noisy values). Line 3: A space-separated list of integers representing the signal stream. Output Format: A single integer representing the maximum length. Example: Input: 10 20 2 5 12 15 25 18 30 22 14 Output: 5 (Explanation: The segment [5, 12, 15, 25, 18] has two noisy values (5, 25). Length is 5.)

Key concepts

two_pointerssliding_window

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.