Code RoomMinimum batches
EasyPrep Room Coding #643

Minimum batches

CodingAlgorithms & data structuresEntry–Mid~11 min

You are given a list of item sizes and a batch limit. Split the list into the fewest possible batches of consecutive items, keeping the original order, such that no batch's total size exceeds the limit. Every individual size is at most the limit. Return the number of batches. Example: sizes [4, 4, 3, 6] with limit 8 needs 3 batches: [4, 4], [3], [6].

Implement
min_batches(sizes: list[int], limit: int) → int
Examples
in[[4,4,3,6],8]out3
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 11 min
InputExpectedGot
[[4,4,3,6],8]3not run yetsample