Question bank › Two Pointers
Dsa Two Pointers Easy

Priority Transit Buffer

A network router has a buffer that can hold packets with a total weight up to 'Capacity'. Some packets are marked as 'Priority' (1) and others are 'Standard' (0). Find the length of the longest contiguous sequence of packets that fits within the Capacity and contains at least 'MinP' priority packets. Input Format: Line 1: Two integers N (number of packets), C (Capacity), and K (MinP). Line 2: N integers representing packet weights. Line 3: N integers (0 or 1) representing priority status. Example: Input: 5 10 1 4 2 3 5 1 0 1 0 0 1 Output: 3 Explanation: Subarray weights [4, 2, 3] sum to 9 (<= 10) and have one priority packet (at index 1). Length is 3.

Key concepts

sliding_windowtwo_pointers

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.