Fruits Into Baskets II
You are given two arrays of integers, fruits and baskets, each of length n, where fruits[i] represents the quantity of the i^th type of fruit, and baskets[j] represents the capacity of the j^th basket.
From left to right, place the fruits according to these rules:
- Each fruit type must be placed in the leftmost available basket with a capacity greater than or equal to the quantity of that fruit type.
- Each basket can hold only one type of fruit.
- If a fruit type cannot be placed in any basket, it remains unplaced.
Return the number of fruit types that remain unplaced after all possible allocations are made.
Example 1
Input
fruits = [4,2,5], baskets = [3,5,4]Output
1The fruit quantities 4 and 2 are placed into baskets with capacities 5 and 3 respectively, while the fruit quantity 5 cannot be placed in the remaining basket of capacity 4.
Example 2
Input
fruits = [3,6,1], baskets = [6,4,7]Output
0All fruit types can be placed by choosing the leftmost available basket with sufficient capacity for each fruit type in order.
Constraints
- n == fruits.length == baskets.length
- 1 <= n <= 100
- 1 <= fruits[i], baskets[i] <= 1000