Dsa
Queue
Easy
Strict Batch Processor
You are designing a data ingestion pipeline. Data items are collected in a queue. Items must be released in batches of exactly size K. If a special 'FLUSH' command enters the queue, all currently queued items must be released immediately as a partial batch. Write a program that reads K and a sequence of strings, and prints each released batch on a new line with items separated by hyphens.
Example:
Input: 3 A B C FLUSH D E F G FLUSH
Output:
A-B-C
D-E-F
G
Key concepts
queuebufferbatching
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