Assign Cookies
Assume you are an awesome parent and want to give your children some cookies. You should give each child at most one cookie.
Each child i has a greed factor g[i], which is the minimum size of a cookie that the child will be content with. Each cookie j has a size s[j]. If s[j] >= g[i], you can assign cookie j to child i, and child i will be content.
Your goal is to maximize the number of content children and return the maximum number.
Note: This question is the same as 2410: Maximum Matching of Players With Trainers.
Example 1
Input
g = [1,2,3], s = [1,1]Output
1Only the child with greed factor 1 can be content because both cookies have size 1.
Example 2
Input
g = [1,2], s = [1,2,3]Output
2The cookies are large enough to make both children content, so the maximum number is 2.
Constraints
- 1 <= g.length <= 3 * 10^4
- 0 <= s.length <= 3 * 10^4
- 1 <= g[i], s[j] <= 2^31 - 1