#3479
Fruits Into Baskets III
expert · 1035 · lc medium +32 · 38.9% accepted · 600 likes · top 18%
Description
Each entry in fruits gives the quantity of one fruit type; each entry in baskets gives a basket\'s capacity. Process fruit types from left to right:
- Place each fruit in the first available basket whose capacity meets or exceeds the quantity.
- A basket can hold only one fruit type.
- Fruits with no suitable basket remain unplaced.
Return how many fruit types ended up unplaced.
Code
1
2
3