Content Children — Solution & Editorial
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)
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)