Greedy Algorithms8 sections · 316 units
Open in Course

Problem - Assign Cookies

Satisfy children

Each child has a greed factor. Each cookie has a size. A child is satisfied if they get a cookie with size at least their greed. Maximize satisfied children. For greed=[1,2,3]greed = [1,2,3] and cookies=[1,1]cookies = [1,1], answer is 11. Only one child can be satisfied.

Here's a classic matching problem.

Think about which child to satisfy first with which cookie.