DeepOffer

Implement k-means clustering on a shared doc.

ML CodingReported interview question
Reported in interviews — Google, Dec 2019

Initialize centroids, assign each point to its nearest centroid, recompute means, and repeat until assignments or objective stabilize. Handle empty clusters and use vectorized squared distances; multiple k-means++ restarts reduce bad local optima.

Test empty input, one-element input, duplicates, boundary indices, invalid states, and the largest allowed size; state time and space complexity.

Common follow-up questions

Practice this question with an AI interviewer

Get asked follow-ups live, then receive a scored report — like a real MLE interview loop.

Start AI mock interview