AI Interviews · Question

AI-enabled coding screen: an easy, multi-step "delivery rate" problem, followed by questions on its time and memory complexity.

AI-assisted coding question reported at OpenAI (2026). Sources, confidence and an answer card.

Researched · updated

eng-094 Both tracks AI-assisted coding rounds AI-assisted coding Medium confidence
On this page

What they’re really asking

If you only remember one thing, say this in the first minute: “First I’ll pin down what ‘delivery rate’ means: delivered over attempted, per key, over which time window, and what we return when there’s no data. Then I’ll build the simplest correct version, a single pass with two counters per key, and widen it one step at a time with tests for each step. The assistant can type the code and the test tables. When you ask about complexity, I’ll answer for the code that’s actually on the screen, including anything the assistant added.”

The rest of this page explains each part of that answer.

The question asks two things. Can you build a small problem that grows in steps, cleanly, with AI help? And can you then defend its cost yourself?

In a normal coding round, the complexity question checks your algorithm. Here the code was partly typed by an assistant: a chat tool backed by a large language model (LLM), a program trained on huge amounts of text and code that writes a plausible reply to what you type. Generated code often carries small extra costs you didn’t ask for, like a sort inside a loop or a copy on every call. The complexity follow-up checks that the code on the screen is still yours: that you read it closely enough to know what it costs.

One account from an OpenAI forward-deployed engineer (an engineer who builds directly with customers) describes an AI-enabled live-coding screen with an easy, multi-step “delivery rate” problem, followed by questions on time and memory complexity (Acedfirst-hand · 2026). The account gives few details of the problem itself, so this card works from its shape: a metric computed over events, extended step by step.

Clarify first

  • What is a “delivery”, and what is the rate? Delivered over attempted, deliveries per second, or per driver or region? Ask for one worked example.
  • Over what window? All time, a fixed window, or a sliding window ending now?
  • Input. A list in memory, a stream, or events arriving out of order? Are timestamps sorted?
  • Output precision and empty cases. What is the rate with zero attempts? Assume an explicit “no data” value, not 0.
  • Policy. AI is reportedly banned in most OpenAI rounds and allowed in some formats (interviewing.iosecondary · 2026), so confirm what this round allows.

Answer

Words you need first

  • Key: what you group by, such as a region or a driver.
  • Fixed window: counts reset at set times (each minute on the clock).
  • Sliding window: “the last 60 seconds, ending now”. As time moves, old events fall out.
  • Amortized O(1): each event is added once and removed once, so the average cost per event is constant even if one call sometimes removes many.

The worked example: one region, six deliveries

Assume the interviewer confirms “delivered ÷ attempted, per region, over the last 60 seconds”. Follow region north through the steps:

Time (s)EventWindow holds (last 60 s)RateWhat to say in the interview
0attempt, delivered1 of 11.00”Two counters per key: delivered and attempted.”
10attempt, failed1 of 20.50”Each event updates both counters.”
30attempt, delivered2 of 30.67
55attempt, delivered3 of 40.75
65attempt, failedthe event at 0 s has left: 2 of 40.50”Before reading, evict events older than 60 seconds from the front of the queue.”
200(query only)nothing in the last 60 sno data”Return ‘no data’, not 0. A dashboard shows 0 as a total outage.”

Every row is a test case you can dictate to the assistant. The last two rows are the ones a draft most often gets wrong.

Step 1: the simplest correct version

Say the data model first: events with a timestamp, a key and an outcome. A first version over a list is a single pass with two counters per key: O(n) time for n events, and O(k) memory for k keys. Let the assistant write it, along with the table of test cases you dictate: no events, all failures, one key, many keys.

Step 2 and later: widen deliberately

Typical extensions for this shape are a time window and a query API.

  • Exact sliding window. For sorted events, keep a queue of events per key and evict from the front as the window moves. That is amortized O(1) per event, and memory grows with the number of events in the window.
  • Bucketed window. If memory matters more than exactness, split the window into fixed slots (for example 60 one-second slots) holding two counters each, and accept a small error at the bucket edges. Memory is then fixed per key, however busy the key is.

Say which one you chose and why before prompting: “I’ll start exact, because the tests check exact boundaries. If memory were the constraint, I’d switch to 60 one-second buckets.” The box below shows when that switch is worth it.

The arithmetic behind the numbers (for a Staff-level follow-up)
  • Exact queue, assumed busy key: at an assumed 1,000 events a second, a 60-second window holds 1,000 × 60 = 60,000 events for that key.
  • Buckets: 60 slots × 2 counters = 120 numbers per key, whatever the traffic.
  • The cost of buckets: an event at 59.9 s and one at 59.1 s share a slot, so the window edge is only accurate to one second. For a dashboard that is usually fine; for a billing rule it may not be.

Own the complexity answer

When asked, answer for the code as written, including what the assistant added:

  • a sort inside the query (O(n log n) per call);
  • a list copied on every update;
  • a map rebuilt per query.

If you see one, say it and fix it: “The draft sorts on every query. Events arrive sorted, so I’ll drop that and the query is O(1) after eviction.” That is the point of the follow-up.

Verify

Run the tests after each step. Add a boundary test exactly at the window edge (an event exactly 60 seconds old: in or out? Decide, and test it). Add one with out-of-order timestamps if the input allows them.

Senior vs Staff

Multi-step metric problem

Senior

  • Clarifies the definition and window, ships each step with tests, and states complexity for the code actually written.

Staff

  • Names the exactness versus memory trade-off (exact queue versus buckets) and what traffic or accuracy need would flip it.

Small-team version

Rates over windows are everywhere in a small company’s product: delivery success, error rates on calls to an AI provider, per-customer usage.

  • Don’t build a metrics system. Compute the rate in the database or your observability tool, which you already pay for, and write code only for the product-facing piece.
  • When an agent writes the windowing code, you own two tests: the exact boundary case and the empty window. Those are the bugs that reach a customer’s dashboard.
  • Reuse a known shape. The same sliding-window structure, with one-second buckets, is in this site’s Build Your Own Distributed Rate Limiter lab.

Pitfalls

  • Coding before agreeing on what “rate” and “window” mean. Three reasonable readings give three different programs.
  • Returning 0 for no data. On a dashboard it reads as a total failure.
  • Quoting complexity for the algorithm you intended. The interviewer asks about the code the assistant produced.
  • An off-by-one at the window boundary. Decide whether an event exactly 60 seconds old counts, and test it.

Go deeper

Family

AI-assisted coding round in a provided codebase

Meta-style rounds (and their Microsoft, OpenAI, Apple and Fireworks cousins): fix a bug, build a feature and make it faster in a repo you've never seen, with an AI assistant you direct, check and sometimes overrule.

Other questions in this family