[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2023-10-10 11:27:13 +00:00
parent 96f6c59a42
commit 78e80dfcea

View File

@ -1,6 +1,6 @@
"""
You're a caring parent, and you want to give your children cookies. Each child has a specific cookie size they like (their "greed factor").
You have different-sized cookies. Your goal is to give cookies to as many children as possible by matching the cookie size to
You're a caring parent, and you want to give your children cookies. Each child has a specific cookie size they like (their "greed factor").
You have different-sized cookies. Your goal is to give cookies to as many children as possible by matching the cookie size to
each child's greed factor. How many children can you make happy?
Example: g = [1,2,3], s = [1,1], where g is the greed factor and s is the cookie size.
@ -24,6 +24,7 @@ This method ensures that you maximize the number of happy children efficiently."
"""
from typing import List
def max_happy_children(greed_factors: List[int], cookie_sizes: List[int]) -> int:
"""
Calculate the maximum number of happy children by distributing cookies.
@ -44,10 +45,10 @@ def max_happy_children(greed_factors: List[int], cookie_sizes: List[int]) -> int
"""
greed_factors.sort()
cookie_sizes.sort()
child = 0
for cookie in cookie_sizes:
if child < len(greed_factors) and cookie >= greed_factors[child]:
child += 1
return child
return child