Hand-Written K-Means

Asked at Microsoft · Coding Questions · Difficulty: Medium · Last asked Feb 13, 2026

Implement K-Means from scratch in numpy / PyTorch / plain Python. The Microsoft HM (Applied Scientist 2) phone screen routinely opens with this; sometimes followed by a time-complexity discussion.

Loading the problem…