Code Room
CodingEasy
Question
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) → intExamples
in
[[4,4,3,6],8]out3What 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.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.