Van loading with greedy fit
A courier loads parcels onto vans in the order they come off the belt, and cannot reorder them. Every van holds van_capacity kilograms. The loader always puts the next parcel into the van that has the most free space right now, ties going to the van that opened earlier. If the parcel does not fit in that van, a new empty van is opened and the parcel goes there. A parcel never exceeds van_capacity, and a parcel of zero kilograms still has to be loaded somewhere. Return the free space left in every van once the belt is empty, sorted ascending. Return an empty list when there are no parcels.
van_leftover_space(parcel_sizes: list[int], van_capacity: int) → list[int][[5,4,3,4],10]out[1,3][[7,7,7],10]out[3,3,3][[6,5,3,5],10]out[2,4,5]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.
[[5,4,3,4],10][1,3]not run yetsample[[7,7,7],10][3,3,3]not run yetsample[[6,5,3,5],10][2,4,5]not run yetsample