easy +10 pts

Assign Cookies

Maximize content children by matching cookie sizes to greed factors.

You are a teacher distributing cookies to children. Each child has a greed factor g, which is the minimum cookie size they will accept. Each cookie has a size s. A child will be content if they receive a cookie with size >= their greed factor. Each cookie can be given to at most one child, and each child can receive at most one cookie. Write a function `find_content_children(g: list[int], s: list[int]) -> int` that returns the maximum number of children who can be content. The function should work efficiently by sorting both lists and using a greedy approach. Do not modify the input lists in place unless you make a copy; the original lists should remain unchanged. Examples: ```py >>> find_content_children([1, 2, 3], [1, 1]) 1 >>> find_content_children([1, 2], [1, 2, 3]) 2 ```

Constraints

- 0 <= len(g) <= 10^4 - 0 <= len(s) <= 10^4 - 0 <= g[i], s[i] <= 10^4 - Expected time complexity: O(n log n + m log m), where n = len(g), m = len(s). - Expected space complexity: O(1) extra (excluding input).

Example

```py
# Example 1
>>> find_content_children([1, 2, 3], [1, 1])
1

# Example 2
>>> find_content_children([1, 2], [1, 2, 3])
2

# Example 3 (child with greed 0)
>>> find_content_children([0, 1], [1])
1
```
10 points ~15 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Sort both lists in ascending order.
Use two pointers: one for children (g) and one for cookies (s).
If the current cookie satisfies the current child, move both pointers and increment the count. Otherwise, advance only the cookie pointer.
Stop when either list is exhausted.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.