Back to problems

Belt Packing: Return a Triplet When 3 Items Fit a Threshold

Algorithm · Google · Hard

Problem: Conveyor Belt Packing (Strict Threshold, Streaming Triplet Return) Items arrive one at a time on a conveyor, and every item carries an integer size. A group of three items a, b, and c is eligible for packing whenever: max(a,b,c) - min(a,b,c) < threshold Create a Packer class with the following behavior: Construct it using threshold. Its add(x) operation adds a newly arrived item whose size is x. Once the insertion leaves at least one eligible group of three, add…

Checking your access…