PracHub
QuestionsLearningGuidesInterview Prep
|Home/Machine Learning/Atlassian

Minimize L1 Distance with k Cluster Centers in Array

Last updated: Mar 29, 2026

Quick Overview

Atlassian machine learning and algorithms prompt on one-dimensional k-center clustering with L1 distance, covering sorting, binary search on radius, greedy feasibility, interval covering, precision, and complexity.

  • 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: Atlassian machine learning and algorithms prompt on one-dimensional k-center clustering with L1 distance, covering sorting, binary search on radius, greedy feasibility, interval covering, precision, and complexity.

Related Interview Questions

  • Minimize max L1 radius with k centers in 1D - Atlassian (medium)
  • Train and evaluate logistic model with regularization - Atlassian (medium)
|Home/Machine Learning/Atlassian

Minimize L1 Distance with k Cluster Centers in Array

Atlassian logo
Atlassian
Jul 12, 2025, 6:59 PM
mediumData ScientistTechnical ScreenMachine Learning
16
0

One-Dimensional k-Center Clustering With L1 Distance

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

Return the minimum possible maximum distance, also called the optimal radius.

Constraints & Assumptions

  • Distance is absolute difference: |x - c| .
  • Centers may be placed anywhere on the real line, not necessarily at input points.
  • Duplicate input points are allowed.
  • If the optimal radius is a half-integer and an integer answer is required, state how you would handle precision or scale coordinates by 2.

Clarifying Questions to Ask Guidance

  • Should the result be an exact integer, a floating-point radius, or a scaled integer?
  • Are centers required to be input points?
  • What are the constraints on n , coordinate range, and k ?
  • Do we need to return the centers or only the minimum radius?

What a Strong Answer Covers Guidance

  • Sort the points first.
  • Convert the problem to covering sorted points with at most k intervals of length 2R .
  • Use binary search on radius R .
  • Use a greedy feasibility check: start at the leftmost uncovered point p , place a center at p + R , cover all points up to p + 2R , and repeat.
  • Explain why greedy is optimal for a fixed radius in one dimension.
  • Analyze complexity, typically O(n log range) for binary search with greedy feasibility.
  • Discuss floating precision versus integer scaling, duplicates, and edge cases such as k >= n .

Follow-up Questions Guidance

  • How would the solution change if centers must be selected from input points?
  • Can you solve the sum of L1 distances variant with dynamic programming?
  • What happens when k = 1 ?
  • How would you reconstruct the chosen centers?
Loading comments...

Browse More Questions

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

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

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

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding 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.