PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Machine Learning/Atlassian

Minimize L1 Distance with k Cluster Centers in Array

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of clustering and metric-based optimization, focusing on L1 distance and interval covering in a one-dimensional setting and belongs to the Machine Learning and algorithms domain with a practical application focus on algorithm design and optimization.

  • medium
  • Atlassian
  • Machine Learning
  • Data Scientist

Minimize L1 Distance with k Cluster Centers in Array

Company: Atlassian

Role: Data Scientist

Category: Machine Learning

Difficulty: medium

Interview Round: Technical Screen

##### Scenario You have a one-dimensional data set and want to compress it by choosing k representative points while guaranteeing every data point stays close to some representative. ##### Question Given an array of n integers and an integer k, place k cluster centers to minimize the maximum L1 distance between any point and its nearest center. Output this minimum possible distance. ##### Hints Consider sorting, binary searching the radius, and greedy or DP feasibility checks.

Quick Answer: This question evaluates understanding of clustering and metric-based optimization, focusing on L1 distance and interval covering in a one-dimensional setting and belongs to the Machine Learning and algorithms domain with a practical application focus on algorithm design and optimization.

Related Interview Questions

  • Minimize max L1 radius with k centers in 1D - Atlassian (Medium)
  • Train and evaluate logistic model with regularization - Atlassian (medium)
Atlassian logo
Atlassian
Jul 12, 2025, 6:59 PM
Data Scientist
Technical Screen
Machine Learning
15
0

1D k-Center (Minimax L1) Clustering

Problem

You are given an array of n integers on a number line and an integer k (1 ≤ k ≤ n). Place k cluster centers on the real line to minimize the maximum L1 (absolute) distance between any point and its nearest center.

  • Distance between a point x and a center c is |x − c|.
  • Centers may be placed anywhere on the real line (not necessarily at input points).
  • Output the minimum possible maximum distance (the optimal radius).

Goal

Return the optimal radius R* such that all points can be covered by k intervals of radius R* around the chosen centers, and no smaller radius suffices.

Notes

  • Think of this as covering all sorted points with k intervals of length 2R.
  • Typical approach: sort, binary search on R, and use a greedy feasibility check.
  • If you must return an integer and the true optimum is a half-integer, you can either output a floating value (e.g., with 1e-6 precision) or scale coordinates by 2 to keep everything integral.

Solution

Show

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Machine Learning•More Atlassian•More Data Scientist•Atlassian Data Scientist•Atlassian Machine Learning•Data Scientist Machine Learning
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.