Algorithm · Airbnb · Easy
Build an allocator that fills a single order from stock on hand. A single order asks for some total quantity, and the warehouse holds a sequence of inventory batches, each identified by a unique reference_id and carrying an available quantity. The batches arrive in age order, oldest first, and stock must be drawn first-in, first-out: exhaust older batches before touching newer ones. Report how many units are taken from each batch, and if the combined stock falls short of the…