K-Means Clustering

In a k-means clustering problem, a dataset contains n data points, where i data point is represented by the feature vector location[i]. The goal is to create k clusters. where the cluster centers or the cluster centroids can be placed at any point in the feature space. The overall quality of the clustering is measured by the maximum distance between any data point and its nearest cluster center.

The best possible quality is achieved by optimally placing the cluster centers to minimize this maximum distance. Determine this maximum distance between any data point and its nearest cluster center.

Note: The distance between two feature points x and y is defined as |x - y|, where |x| denotes the absolute value of x.

**My deepest and boundless gratitude to the incredible friend who so kindly shared this resource! **

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: