LeetCode 455 Assign Cookies - Problem Statement

The problem

You're a parent with cookies to distribute. Each child has a greed factor; they're satisfied only if the cookie size is at least their greed factor.

Maximize the number of satisfied children.

With g = [1,2,3] (greed factors) and s = [1,1] (cookie sizes):

  • Child with greed 1 can be satisfied by cookie of size 1.
  • Child with greed 2 needs at least size 2. Only size 1 cookies left.
  • Child with greed 3 can't be satisfied.
  • 11 child satisfied.

With g = [1,2] and s = [1,2,3]:

  • Child 1 gets cookie 1. Child 2 gets cookie 2. (Or cookie 3.)
  • 22 children satisfied.

Constraints: 11 \le g.length, s.length 3×104\le 3 \times 10^4.