Assign Cookies Problem
Assign Cookies Problem — ExecCode Easy DSA Practice
Solve the Assign Cookies problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Each child i has a greed factor g[i], the minimum cookie size that will content them, and each cookie j has a size s[j]. A cookie can satisfy a child if its size is at least the child's greed factor. Maximize the number of content children.
Examples
Input g = [1, 2, 3], s = [1, 1]; Output 1. Input g = [1, 2], s = [1, 2, 3]; Output 2. Input g = [10, 9, 8, 7], s = [5, 6, 7, 8]; Output 2
Constraints
1 ≤ g.length ≤ 3 × 10⁴ 0 ≤ s.length ≤ 3 × 10⁴ 1 ≤ g[i], s[j] ≤ 2³¹ - 1
Practice Assign Cookies free on ExecCode. Browse DSA problems, topic map, and placement guides.