#3477
Fruits Into Baskets II
newbie · 290 · lc easy +20 · 70.2% accepted · 504 likes · top 79%
Description
Arrays fruits and baskets each have length n. Place each fruit type into a basket following these rules (processed left to right):
- Assign the fruit to the leftmost available basket whose capacity is at least the fruit\'s quantity.
- Each basket holds at most one fruit type.
- If no basket can accommodate a fruit type, it goes unplaced.
Return the count of fruit types that could not be placed.
Code
1
2
3