EASYasked at 3 companies

Assign Cookies

A easy-tier problem at 54% community acceptance, tagged with Array, Two Pointers, Greedy. Reported in interviews at Accenture and 2 others.

Founder's read

Assign Cookies shows up in real assessments at Microsoft, Atlassian, and Accenture. It looks trivial on the surface, match kids to cookies by size, but the greedy insight isn't obvious under pressure. A 54% acceptance rate means half the people solving it are either missing the pattern or overthinking it. You probably won't spend 20 minutes on it, but the moment you blank on whether to sort or match greedily, that's when StealthCoder surfaces the working solution in seconds, invisible to the proctor.

Companies asking
3
Difficulty
EASY
Acceptance
54%

Companies that ask "Assign Cookies"

If this hits your live OA

Assign Cookies is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.

Get StealthCoder
What this means

The trick is greedy matching with two pointers after sorting both arrays. Sort kids by greed factor, sort cookies by size, then walk both lists in parallel. Assign the smallest cookie that satisfies the least-greedy kid, moving forward. Most people either try a brute force O(n²) loop or fumble the pointer logic and wind up skipping valid assignments. The pattern is pure greedy: always pair the hungriest remaining kid with the smallest cookie that works. It's a two-pointer warmup that tests whether you automatically think sorting-plus-greedy before coding. StealthCoder catches the moment you lock onto the wrong approach and delivers the correct traversal instantly.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Assign Cookies recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Assign Cookies interview FAQ

Is Assign Cookies still asked at FAANG?+

Yes. It appears in assessments at Microsoft and similar tier-1 companies. It's typically a screening problem, not a main-loop focus. The 54% acceptance rate means it's easy to fail under time pressure, so interviewers still use it to filter candidates who panic or overcomplicate.

What's the actual trick?+

Sort both arrays, then use two pointers to match kids greedily. For each kid starting from least greedy, assign the smallest cookie that satisfies them. Move both pointers forward. The greedy choice is optimal because smaller kids are easier to satisfy, freeing larger cookies for greedier kids.

What mistake do most people make?+

Trying to iterate one array and search the other without sorting first, leading to O(n²) or failed logic. Or sorting correctly but then iterating both pointers wrong, skipping valid assignments. The mental block is not immediately seeing that sorting unlocks a one-pass solution.

How does Greedy apply here vs. other array problems?+

Greedy works because the problem has the exchange property: swapping assignments never makes things worse. Pair the hungriest kid with the smallest cookie that works, always. Array and Sorting are prerequisites. Two Pointers is the execution pattern once you decide to sort.

How much prep time do I need for this?+

If you know the greedy sort-plus-two-pointer pattern, 10 minutes to code and test. If you don't, you'll burn 20-30 minutes trying brute force or pointer logic. The gap is entirely pattern recognition. One solved example and you won't forget it.

Want the actual problem statement? View "Assign Cookies" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.