Description
You have children with greed factors and cookies with sizes. A child is satisfied if cookie size >= greed factor. Each cookie can be given to at most one child. Maximize satisfied children.
Examples
Input:
g = [1,2,3], s = [1,1]Output:
1Explanation:
Only child with greed 1 satisfied.
Input:
g = [1,3,5,4], s = [2,1,3]Output:
2Explanation:
Sort children [1,3,4,5] and cookies [1,2,3]. Child with greed 1 gets cookie size 1. Child with greed 3 gets cookie size 3. Children with greed 4 and 5 cannot be satisfied. Total: 2 children satisfied.
Input:
g = [5,6,7], s = [1,2,3,4]Output:
0Explanation:
All children have greed factors (5,6,7) larger than any available cookie sizes (1,2,3,4). No child can be satisfied, so the answer is 0.
Constraints
- •
1 ≤ g.length ≤ 3 × 10⁴