61Build a customer-support agent over a fake product/SQL database: tool-calling, retrieval, and a control loop.▼hardSierraDecagonOpenAI2 replies◆ premiumA live-coding round that tells apart engineers who have shipped agents from those who have only read about them. Interviewers want a genuine plan-act-observe loop, tools that query a real SQL database, guardrails that block the obvious failures, and a concrete evaluation plan, rather than one prompt masquerading as an agent.Open full answer →
62Build a small in-memory document indexer and retriever from scratch (inverted index + BM25), then add a vector option.▼mediumAppleGleanAnthropic2 replies◆ premiumA bridge connecting classic DSA and modern RAG. Interviewers want to see you build a working inverted index and a correct BM25 score by hand, reason about its complexity, and then know precisely when you would switch to embeddings and an ANN index instead.Open full answer →
95Build an in-memory key-value database, then extend it across stages: TTL, transactions, snapshots.▼hardAnthropicOpenAIGoogle1 replies◆ premiumThe classic multi-round build screen: a plain key-value store that gains new requirements at each stage (TTL, transactions, scans). The signal is not stage 1, it is whether your code takes on stage 4 without a rewrite. Here is how to design for it.Open full answer →
96Implement a GPU credit allocation manager: issue credits, track usage, enforce limits and expiry.▼hardOpenAIAnthropicNVIDIA1 replies◆ premiumOpenAI's signature build screen: a credit ledger that issues GPU-hours, spends them, and lets unused grants lapse in issue order. The trap is charging against the right grant first. Here is the FIFO-by-expiry design that holds up through every follow-up.Open full answer →
97Implement an in-memory key-value store with transactions: begin, commit, rollback, and nesting.▼hardAnthropicOpenAIGoogle2 replies◆ premiumA classic build screen: a key-value store whose writes inside a transaction can be committed or discarded, with transactions that nest. The trap is mutating the base store directly. Here is the overlay-stack design that keeps rollback O(1).Open full answer →
98Convert sampled call-stack profiler data into a flame tree and find the slowest function.▼mediumGoogleOpenAIApple1 replies◆ premiumA practical build screen: transform a stream of sampled call stacks into a flame tree, then report self-time against total-time per function. The trap is mixing up the two times. Here is how to aggregate the tree and rank the hot functions.Open full answer →
99Find duplicate files in a directory tree by content: size prefilter, then hashing.▼mediumGoogleAppleAmazon2 replies◆ premiumA grounded systems-coding screen: locate files with identical content across a tree. The naive all-pairs hash wastes work. The signal is the size prefilter plus a cheap-hash gate ahead of the full hash. Here is the layered approach.Open full answer →
101Simulate infection spreading across a 2D grid with multi-source BFS, passing staged test cases.▼mediumGoogleAmazonMeta2 replies◆ premiumThe rotting-oranges family of build screens: a state expands outward one step per tick across a grid, with the spec adding rules each round. The signal is multi-source BFS processed by layers, not per-cell loops. Here is the design that absorbs each new test case.Open full answer →
103Build a spreadsheet cell-dependency engine: evaluate formulas and detect circular references.▼hardSierraGoogleApple2 replies◆ premiumSierra's signature build screen: cells hold values or formulas that reference other cells, and editing one has to recompute its dependents without infinite loops. The signal is the dependency graph plus cycle detection. Here is the topological-eval design.Open full answer →
104Build a small tool to a loosely defined, shifting spec: clarify, structure for change, adapt mid-session.▼mediumGoogleAnthropicOpenAI2 replies◆ premiumGoogle's 'vibe coding' screen: the spec is intentionally vague and shifts mid-interview. The signal isn't the algorithm, it's whether you clarify before coding, structure for change, and keep tests green as the requirements move. Here is how to run that loop.Open full answer →
117Build a decision tree classifier from scratch: pick splits by Gini or entropy, then predict.▼mediumAmazonGoogleMeta2 replies◆ premiumA from-scratch classic that checks recursion plus the split criterion math. The signal is computing impurity correctly, picking the best threshold by information gain, and knowing the stopping rules. Here is a clean recursive implementation.Open full answer →
119Implement PCA from scratch via SVD: center the data, project onto top components, report variance.▼mediumGoogleMetaNVIDIA2 replies◆ premiumA from-scratch favorite that probes linear algebra fluency. The signal is centering first, using SVD instead of forming the covariance matrix, and reading variance off the singular values. Here is the implementation and the details interviewers push on.Open full answer →
120Implement a Gaussian Mixture Model with EM from scratch: E-step responsibilities, M-step updates.▼hardGoogleMetaNVIDIA2 replies◆ premiumA build-it-yourself check on the EM algorithm and soft clustering. What matters is the pair of alternating steps (responsibilities, then weighted re-estimation), log-sum-exp for numerical stability, and seeing how GMM extends k-means. The code follows.Open full answer →
126Build a tiny autograd engine from scratch: a scalar Value with backprop over a computation graph.▼hardOpenAIGoogle DeepMindMeta2 replies◆ premiumA build-it-yourself check on how PyTorch actually works under the hood. What matters is assembling a computation graph during the forward pass, local derivatives per op, and a topological-order backward pass that accumulates gradients. Below is a minimal engine.Open full answer →
127Implement a WordPiece tokenizer from scratch: greedy longest-match-first subword segmentation.▼mediumGoogleHugging FaceOpenAI1 replies◆ premiumA build-it-yourself check on subword tokenization. What matters is greedy longest-match encoding against a fixed vocabulary, the continuation-prefix convention, and how WordPiece diverges from BPE. The code follows.Open full answer →
128Build a mini data loader with sharding for distributed training: split data across workers without overlap.▼mediumMetaNVIDIAGoogle2 replies◆ premiumA build-it-yourself check on distributed input pipelines. What matters is partitioning data across workers with no overlap and no gaps, epoch-consistent shuffling with a shared seed, and handling the uneven-last-batch problem. The code follows.Open full answer →
129Write a JSON parser from scratch. Now make it handle the partial JSON an LLM streams mid-generation.▼hardOpenAIAnthropicDatabricks◆ premiumThe classic recursive-descent exercise with an applied-AI twist: the JSON your model streams stays truncated mid-token for the whole generation. What matters is a clean strict parser plus a small repair layer, not a second parser. The code follows.Open full answer →
130Write an async batch caller for an LLM API: N requests, a concurrency cap, timeouts, and retries with backoff.▼mediumOpenAIAnthropicScale AI◆ premiumThe most job-shaped coding screen in AI, ML, and GenAI engineering: fan out N LLM calls without melting the rate limit or losing the batch to one bad request. What matters is the retry policy, not the async syntax. Below is the version that passes.Open full answer →
131Implement a conversation memory system: buffer, sliding window, summary, and token-budget eviction.▼mediumOpenAIAnthropicLangChain◆ premiumThe most-asked hands-on LLM exercise: a chat history that outgrows the context window. What gets scored is not the sliding window, it is the region eviction is never allowed to touch. Below is the version that passes.Open full answer →
132Write token counting and context-window packing for an LLM call: fit the budget, reserve room for the completion.▼mediumOpenAIAnthropicCohere◆ premiumEvery RAG system packs a prompt, and the packing bug is always the same one: the input fits the window exactly, so the model has nowhere left to answer. The arithmetic here is what separates a candidate who has shipped from one who has read about it.Open full answer →
133Implement a semantic cache for LLM responses. When is a similar-enough query actually a hit?▼hardOpenAIAnthropicPerplexity◆ premiumThe lookup is three lines of linear algebra. What separates a cache from an incident is where the similarity threshold came from, and the one-token queries ('2023' vs '2024', 'not') that no threshold can catch because the embedding barely moves.Open full answer →
134Build an LLM-as-a-judge evaluation harness with pairwise comparison and position-bias control.▼mediumOpenAIAnthropicScale AI◆ premiumAsking a model which answer is better is one line of code. Getting a number you would let block a deploy takes position-bias control, a confidence interval, and a human-labeled set the judge is measured against. Here is the harness.Open full answer →
135Write a tool-call handler for an LLM API: schema validation, execution, error feedback, and parallel calls.▼mediumOpenAIAnthropicLangChain◆ premiumEvery agent is a loop around this function. The candidates who fail it raise an exception on a bad tool call; the ones who pass hand the error back to the model as a tool result and let it fix itself on the next turn.Open full answer →
136Implement chunking strategies from scratch: fixed-size, recursive, semantic, and parent-child.▼mediumGleanDatabricksCohere◆ premiumEvery RAG system starts here, and most candidates ship the same bug: they size the chunk in characters and call it tokens. Below is running code for all four strategies, plus the infinite loop in the overlap arithmetic and the one in the recursion.Open full answer →
137Write a prompt-injection detector and evaluate it on an adversarial set.▼mediumAnthropicOpenAIMicrosoft◆ premiumWriting the regexes takes ten minutes. The half of the question that separates candidates is the evaluation: a detector that blocks 'ignore the noise in the data' has shipped a bug to every analyst using your product. Here is the layered detector and the harness that proves it works.Open full answer →
138Implement output guardrails that block off-topic answers and PII leakage, within a latency budget.▼mediumAnthropicMicrosoftStripe◆ premiumThis code runs on every single response, so it sits on the critical path and a heavyweight check here doubles your p95. The signal is in the ordering, the fail-open decision when the guardrail times out, and the fact that you cannot un-send a token you already streamed.Open full answer →
139Implement a cross-encoder reranker and prove it improves nDCG@10.▼mediumCohereGleanElastic◆ premiumAnyone can call a rerank endpoint. The word doing the work in this question is 'prove': you have to implement DCG, ideal DCG, and nDCG@k from graded labels and report the before-and-after. Plus the ceiling nobody mentions until it bites them in production.Open full answer →
140Consume a streaming LLM response: SSE parsing, incremental output, cancellation, and partial JSON.▼mediumOpenAIAnthropicVercel◆ premiumThe naive version splits on newlines and works right up until a TCP chunk lands mid-line. Then there is the error that arrives after a 200 OK, the user who closes the tab while you keep paying for tokens, and JSON you cannot parse until it closes.Open full answer →
141Detect hallucinations in an answer by extracting claims and checking entailment against the sources.▼hardOpenAIAnthropicGlean◆ premiumAsking a model 'is this answer hallucinated?' barely beats a coin flip. This is the build: claim extraction, a judge forbidden from using world knowledge, a denominator that excludes hedges, and one model call per claim, which decides where the check can run at all.Open full answer →
142Build a minimal RAG pipeline end to end: embed, index, retrieve, ground, and cite.▼mediumOpenAIAnthropicGlean◆ premiumEveryone can write the happy path. The screen is decided by the two branches most candidates skip: what the system does when retrieval finds nothing good, and what it does when the model cites a chunk you never sent.Open full answer →
143Build a prompt template and versioning registry with variable substitution and rollback.▼easyOpenAIAnthropicDatabricks◆ premiumA prompt is code, but most teams edit it in a dashboard with no history and then cannot explain last Tuesday's quality drop. This is the small piece of infrastructure that makes prompts reviewable, pinnable, and instantly reversible.Open full answer →
144Build a document parser: PDF to layout-aware text to clean chunks.▼mediumGleanAnthropicDatabricks◆ premiumMost RAG projects do not die at the retriever, they die at ingestion. Naive PDF extraction interleaves columns into nonsense, shreds tables, and stamps the footer into all 4,000 chunks. Here is the parser that survives real documents.Open full answer →
43Extract and clean a usable dataset from a messy real-world database using SQL plus Python (dedupe, types, nulls, joins, validation).▼mediumAnthropicDatabricksSnowflake1 replies◆ premiumThe applied data-wrangling screen: here is a grubby database, turn out a clean analysis-ready table. The signal is profiling before transforming, doing set-based cleaning in SQL and row-level fixes in Python, joining without fanning out rows, and validating the output rather than trusting it.Open full answer →