Code RoomBottle fill classification
EasyPrep Room Coding #4832

Bottle fill classification

CodingDistributed systemsAlgorithms & data structuresEntry–Mid~13 min

A bottling line records the volume in millilitres it poured into each bottle, in the order the bottles left the filler. Quality control reads that log against a target volume and a tolerance. A bottle is in spec when its volume differs from the target by no more than the tolerance in either direction, so a bottle sitting exactly on either edge of the band still counts as in spec. Return exactly three lists: the underfilled volumes, then the in spec volumes, then the overfilled ones. Inside each list keep the order the bottles were logged and keep repeats, since two bottles may pour the same volume. An empty log still returns three lists, all of them empty. The tolerance is never negative.

Implement
partition_fill_volumes(fills_ml: list[int], target_ml: int, tolerance_ml: int) → list[list[int]]
Examples
in[[500,496,503,488,512],500,3]out[[496,488],[500,503],[512]]
in[[750,750,749],750,0]out[[749],[750,750],[]]
in[[],330,5]out[[],[],[]]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 13 min
InputExpectedGot
[[500,496,503,488,512],500,3][[496,488],[500,503],[512]]not run yetsample
[[750,750,749],750,0][[749],[750,750],[]]not run yetsample
[[],330,5][[],[],[]]not run yetsample