Practice Fruits Into Baskets II
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Process fruit types from left to right. Each fruits[i] must be placed in the leftmost unused basket whose capacity baskets[j] is at least fruits[i]. A basket may hold only one type. If no unused basket fits a type, leave it unplaced and continue. Return the number of unplaced types.
Source: Fruits Into Baskets II on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
fruits = [4,2,5], baskets = [3,5,4]
Output
1
# Example 2
Input
fruits = [3,6,1], baskets = [6,4,7]
Output
0
Constraints
n == fruits.length == baskets.length
1 <= n <= 100
1 <= fruits[i], baskets[i] <= 1000
Related LeetCode Problems
Practice more problems similar to Fruits Into Baskets II.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.