What ML coding questions does Meta ask and how do you prepare?
Updated June 18, 2026 · 7 min read · Crack ML Interview
Meta ML and machine learning engineer loops combine a general coding round that resembles LeetCode with an ML-specific coding round that tests implementing primitives and metrics from scratch: AUC, precision and recall, k-means, logistic regression, and basic neural network components. Meta weights clean, readable, production-minded code and proactive complexity and edge-case narration heavily. Expect a follow-up that connects coding to product thinking, such as how an online metric could diverge from your offline metric or how a recommendation score is computed. Prepare both tracks: keep medium-level algorithm fluency and drill hand-written ML primitives with verification.
The Two Coding Tracks at Meta
The general coding round still matters
Meta ML roles retain a general coding round that resembles classic data-structures-and-algorithms interviews: arrays, hash maps, strings, trees, graphs, and dynamic programming at the medium difficulty level, often two questions in around forty-five minutes. The bar is fast, correct, clean code with stated time and space complexity and handled edge cases. Do not neglect this round assuming ML roles skip it; weak general coding sinks otherwise strong ML candidates. Maintain medium-level algorithm fluency, with extra attention to patterns like sliding window, hash maps, and heaps that also appear in data processing tasks.
The ML coding round tests primitives and metrics
The ML-specific round asks you to implement machine learning building blocks from scratch in Python with NumPy, and sometimes PyTorch. Reported question families include implementing evaluation metrics such as AUC-ROC, precision, recall, and F1 by hand; clustering with k-means; logistic regression with gradient descent; and basic neural network components like a forward pass, softmax with numerical stability, or a simple training loop. Meta cares that the code is readable and testable, not just correct, reflecting its production engineering culture, so structure your implementation cleanly and narrate complexity as you go.
What Meta Specifically Rewards
Production-minded, readable code with narration
Meta interviewers consistently reward code that looks like it could be reviewed and merged: clear naming, sensible decomposition into functions, and handled edge cases such as empty input, single-element batches, and numerical overflow. Equally important is proactive narration, stating the time and space complexity after each component and enumerating edge cases before being asked. This habit, rather than raw cleverness, is what Meta debrief feedback highlights, and it is precisely what pure problem-solving practice tends to omit. Practice talking through complexity and edge cases out loud until it is automatic.
The product and metrics follow-up
Meta frequently bridges the coding round into product thinking. After you implement a metric, an interviewer might ask when AUC is a misleading metric, how precision and recall trade off for a specific product, or why an offline metric improvement might not translate to an online gain in an A/B test. After a recommendation-flavored question, they may probe how you would handle the cold-start problem or position bias. Being ready to connect your implementation to product impact and online-offline metric gaps is a distinguishing signal at Meta specifically.
A Focused Preparation Plan
Build a primitives-and-metrics drill list
Assemble a checklist of the most reported Meta ML coding items and hand-write each one cleanly under a time limit: AUC, precision, recall, F1, confusion matrix, k-means, k-nearest neighbors, logistic regression with gradient descent, numerically stable softmax, and a basic forward pass with backprop. Use a runnable environment such as Crack ML Interview LeanCode to verify correctness and catch shape and numerical bugs immediately. Practicing blind implementation followed by instant feedback is the fastest path to the fluency Meta expects, and it builds the narration habit at the same time.
Allocate time across both tracks and rehearse the bridge
Split preparation between the two coding tracks: keep medium-level algorithm practice warm for the general round while spending the larger share on ML primitives and metrics for the ML round, since the latter is where candidates with strong general coding most often fall short. Then rehearse the product-and-metrics bridge: for each metric you implement, prepare a sentence on when it misleads and how it relates to online behavior. Two mock interviews that simulate Meta's format, including the follow-up questions, will calibrate your timing and narration before the real loop.
Meta ML Interview: Round, Focus, and Preparation
| Round | What It Tests | Representative Item | How to Prepare |
|---|---|---|---|
| General coding | DSA fluency, clean code | Medium array/graph/DP problems | Medium-level algorithm practice |
| ML coding | Implement primitives and metrics | Implement AUC, k-means, logistic regression | Hand-write primitives with verification |
| Complexity narration | Proactive analysis | State time/space after each part | Practice narrating out loud |
| Edge cases | Robustness | Empty input, single sample, overflow | Enumerate edge cases before coding |
| Product bridge | Metrics and product thinking | When is AUC misleading? | Prepare metric-to-product talking points |
Who this is for
Strong LeetCode solver weak on ML primitives
Profile: Fluent at medium and hard algorithm problems and confident in the general coding round, but has never implemented AUC or k-means by hand.
Pain points: Sails through the general round but stalls in the ML coding round, unsure how to compute AUC from scratch or implement gradient descent cleanly under time pressure.
Strategy: Redirect a chunk of algorithm-practice time to the ML primitives drill list, hand-writing metrics and simple models with verification. Practice the complexity-and-edge-case narration explicitly, since Meta rewards it heavily. Prepare the metrics-to-product follow-ups so the bridge question does not catch you off guard.
Applied ML practitioner rusty on general algorithms
Profile: Implements ML components fluently and understands metrics deeply, but has not practiced classic data-structures-and-algorithms problems recently.
Pain points: Handles the ML coding round well but underperforms in the general coding round, losing speed on medium graph or dynamic programming problems Meta still asks.
Strategy: Refresh medium-level algorithm patterns, prioritizing the ones that also appear in data processing such as sliding window, hash maps, and heaps. Keep the ML primitives sharp but do not assume the ML role skips the general round. Two timed mocks covering both tracks will surface and fix the weaker side.
FAQ
Q: Does Meta still ask LeetCode-style questions for ML roles?
A: Yes. Meta ML and machine learning engineer loops include a general coding round resembling classic algorithm interviews, in addition to an ML-specific coding round. You need both: medium-level algorithm fluency for the general round and from-scratch ML primitive and metric implementation for the ML round.
Q: What ML primitives should I be able to implement for Meta?
A: Prioritize evaluation metrics like AUC, precision, recall, and F1; clustering with k-means; logistic regression with gradient descent; numerically stable softmax; and a basic forward pass with backprop. Implement each cleanly in NumPy or PyTorch under a time limit, and narrate complexity and edge cases as you write.
Q: How important is code readability versus just getting the right answer at Meta?
A: Very important. Meta has a strong production engineering culture and rewards code that reads like it could be merged: clear naming, sensible structure, handled edge cases, and stated complexity. Correct but tangled code scores worse than slightly slower, clean, well-narrated code that demonstrates engineering discipline.
Want to practice with real, verified ML interview questions from top companies?
Browse the question bank