68Implement k-means clustering from scratch.▼medium★ EssentialMetaGoogleAmazon1 replies◆ premiumThe assign-then-update loop is ten lines; the signal is whether you handle the three things that bite in production: initialization, an empty cluster, and a real convergence test instead of a fixed iteration count.Open full answer →
69Implement a k-nearest-neighbors classifier from scratch.▼mediumAmazonAppleMeta2 replies◆ premiumThere is no training, just storage; the work is at query time. The signal is whether you vectorize the distance computation, break ties sensibly, and know when O(n) per query forces you onto an ANN index instead.Open full answer →
70Implement scaled dot-product attention (the forward pass).▼hardOpenAIAnthropicGoogle2 replies◆ premiumsoftmax(QKᵀ/√d_k)·V in four lines, but the grade is the three details people drop: the √d_k scale, subtracting the row max for numerical stability, and getting the causal mask to add -inf before the softmax, not after.Open full answer →
72Implement linear regression with gradient descent from scratch.▼mediumAmazonGoogleMeta1 replies◆ premiumAn ML coding screen that doubles as a calculus check. Interviewers watch whether you can write the MSE gradient without looking it up, explain what the learning rate actually does, and say out loud when you'd just solve the normal equation instead.Open full answer →