Code Room
CodingMediumcod-g1445
Subject GreedyLevel Entry–Mid~14 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

A bakery takes custom cake orders for tomorrow. Every cake takes exactly one hour, work starts at hour 0, and only one cake is in the oven at a time. deadlines[i] is the hour by which order i must be finished — a deadline of 3 means it must be done at or before hour 3. Orders may be declined. Return the maximum number of orders the bakery can fulfill. Example: deadlines [2, 1, 2] gives 2.

Implement
max_orders(deadlines: list[int]) → int
Examples
in[[2,1,2]]out2
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.