Implement K-means without using numpy.
Asked in the virtual onsite (VO1) stage. Coding round; from the visible post text.
Implement kmeans(points, k, max_iters) using only Python's standard library. Initialize the first centroid with points[0], then repeatedly choose the unselected point farthest from its nearest selected centroid, breaking ties by original order. Assign each point to its nearest centroid, breaking distance ties in favor of the lower cluster index. Recompute centroids as coordinate-wise means. If a cluster is empty, keep its previous centroid. Stop when assignments no longer change or after max_iters iterations.
Return (centroids, labels), where centroids is a list of coordinate lists and labels[i] is the assigned cluster for points[i].
def kmeans(points, k, max_iters):