AiLearn AI Coding
hardStructured · sandbox60 min Premium

Kitchen Orders

Assign orders to stations under priority and timing constraints, greedy scheduling and priority queues with a bug → feature → scale arc.

Greedy / PackingTopo Sort

Problem

A kitchen system receives Order { id, priority, items, readyIn } and assigns them to stations. The starter code has a bug.

Phase 1 — Fix the bug

When multiple orders wait for a free station, they're picked first-come-first-served regardless of priority. The queue must serve higher-priority orders first, breaking ties by arrival.

Phase 2 — Feature

Implement station assignment: each Order has items with preparation times, and some items depend on others. Assign orders to the earliest available station and compute the estimated completion time for the whole batch (makespan) — the time when the last order is done.

Phase 3 — Scale

Rush hour: thousands of orders arrive. The queue operations and assignment must stay efficient.

What interviewers watch

Priority-queue semantics under contention, a greedy assignment rule you can defend, and makespan arithmetic — the AI often double-counts or drops the dependency time.