 All Problems
Assign Cookies
easy
array
greedy
sorting
amazon

Assume you are an awesome parent and want to give your children some cookies. Each child i has a greed factor g[i], which is the minimum cookie size that the child will be content with. Each cookie j has a size s[j].

If s[j] >= g[i], you can assign the cookie j to child i, and the child will be content.

Your goal is to maximize the number of your content children. Return this maximum number.

Example 1:

Input: g = [1,2,3], s = [1,1]
Output: 1

Example 2:

Input: g = [1,2], s = [1,2,3]
Output: 2

Constraints:

  • 1 <= g.length <= 3 * 10^4
  • 0 <= s.length <= 3 * 10^4
  • 1 <= g[i], s[j] <= 2^31 - 1
Run to check your code against the sample cases, or submit to run every case