Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Assign Cookies

Easy Greedy

Each child i has a greed factor g[i] (minimum cookie size that satisfies them) and each cookie j has a size s[j]. A cookie can go to at most one child. Print the maximum number of children that can be satisfied.

Constraints

1 <= n, m <= 3 * 10^4 1 <= g[i], s[j] <= 2^31 - 1

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.