Question bank › Two Pointers
Dsa Two Pointers Easy

Shortest Buffer Window

A data stream consists of a sequence of packet sizes. To process a batch, you need a contiguous subsequence of packets whose total size is at least K. Find the minimum number of packets required to reach this threshold. If no such window exists, return 0. Input Format: Line 1: An integer K representing the target sum. Line 2: A sequence of space-separated integers representing packet sizes. Output Format: A single integer representing the minimum length of the window. Example: Input: 25 10 2 3 15 20 1 Output: 2 (Explanation: The window [15, 20] has sum 35 >= 25 and length 2.)

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.