Problems > Content Children > Editorial

Content Children — Solution & Editorial

Back to the Problem

Sort both lists; walk the cookies in increasing size, satisfying the least greedy unsatisfied child that fits.

Complexity: O(N log N + M log M)