Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Assign Cookies

XPChallenge Points: 10
levelLevel: Easy

You are a kind parent who wants to distribute cookies to your children.
Each child i has a greed factor g[i], representing the minimum cookie size that will make them happy.

Each cookie j has a size s[j].
You can give at most one cookie per child, and each cookie can be given to only one child.

A child will be content if they receive a cookie with a size greater than or equal to their greed factor.
Your goal is to maximize the number of content children and return that number.

Example 1:

Input: g = [2, 3, 5] s = [1, 4, 6]

Output: 2

Example 2:

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

Output: 3

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result