FastPrepAssign Cookies
Problems/Assign Cookies

Assign Cookies

Amazon logoAmazon● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Amazon SDE II phone screen, where the coding question was named only as the well-known cookie-sharing exercise by its public number.

The report gives no wording, examples or limits, so this page states that public problem in our own words with its usual limits.

Our version is about 95% the same as the reported question.

You have some cookies to hand out to children. Each child gets at most one cookie, and each cookie goes to at most one child.

Child i has a greed factor g[i]: the smallest cookie size that makes that child content. Cookie j has size s[j]. If s[j] >= g[i], giving cookie j to child i makes the child content.

Return the largest number of children you can make content.

Function

findContentChildren(g: int[], s: int[]) → int

Examples

Example 1

g = [4,2,1]s = [1,3]return = 2
  • The cookie of size 1 makes the child with greed 1 happy.
  • The cookie of size 3 makes the child with greed 2 happy.
  • No cookie has size 4 or more, so the child with greed 4 stays unhappy.
  • The answer is 2.

Example 2

g = [1,3]s = [3,1]return = 2
  • If the child with greed 1 takes the cookie of size 3, the child with greed 3 is left with size 1, which is too small.
  • Instead, give size 1 to the child with greed 1 and size 3 to the child with greed 3.
  • Both children are happy, so the answer is 2.

Example 3

g = [5,5]s = [1,2,3,4]return = 0
  • Both children need a cookie of size at least 5.
  • The largest cookie has size 4, so no child can be made happy.
  • The answer is 0.

Constraints

  • 1 <= g.length <= 3 * 104
  • 0 <= s.length <= 3 * 104
  • 1 <= g[i], s[j] <= 231 - 1

More Amazon Phone Screen questions

  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Spread Through a GridPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Consistent-Hash Packet RouterPHONE SCREEN · Seen Nov 2026
  • Count Connected ComponentsPHONE SCREEN · Seen Nov 2026
  • Second Largest Distinct ElementPHONE SCREEN · Seen Nov 2026
  • Task SchedulerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · Seen Nov 2026
  • Number of IslandsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Assign CookiesExpedia · PHONE SCREEN · ONSITE INTERVIEWExpedia interview questions
  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Can Every Package Fit in a BoxIMC Trading · OAIMC Trading interview questions
  • Minimum Tunnel Crossing TimeArcesium · OAArcesium interview questions
  • Find Maximum GreatnessTwilio · OATwilio interview questions
  • Binge WatchingVanguard · OAVanguard interview questions
  • Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
  • Minimum Station Tracks for a Train ScheduleBNSF Railway · ONSITE INTERVIEWBNSF Railway interview questions
  • Latest Arrival to Catch a BusAutodesk · OAAutodesk interview questions
  • Minimum Removals to Balance ArraySalesforce · OASalesforce interview questions

Interview reports that mention this question

  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public int findContentChildren(int[] g, int[] s) {
        // Write your code here.
    }
}
Checking account…