n lockers, and lockers[j] is the capacity of locker j. There are n parcels to store, and parcels[i] is the size of parcel i.
The parcels are handled in order, starting from the first. Each one goes into the leftmost free locker whose capacity is at least the parcel's size, and a locker holds only one parcel. If no free locker fits, the parcel is left out and the next one is handled.
Return how many parcels are left out.parcels=[5, 2, 6], lockers=[3, 6, 2] → 1
Parcel 5 does not fit locker 3 and goes into the second one (6). Parcel 2 takes the first locker (3). Only the locker of size 2 is left for parcel 6, so it stays out.
parcels=[1, 4, 4], lockers=[4, 4, 1] → 1
Parcel 1 takes the first locker even though the third would also fit, because the leftmost free one is chosen. Then a 4 goes into the second locker and the last 4 has nowhere to go.
parcels=[2, 2], lockers=[2, 9] → 0
Both parcels fit, one per locker.
parcels=[5, 2, 6], lockers=[3, 6, 2]
1
Run checks the first 3 tests in your browser. Submit checks all 103 tests on the server, hidden ones included.