Maximize Minimum Distance

Problem Overview

  • Pick k of n distinct x-axis points to maximize the minimum distance between any chosen pair.
  • Input: array x and integer k; Output: the largest attainable minimum pairwise distance.
  • Constraints: 2≤n≤1e5, 0≤x[i]≤1e9, all x distinct, 2≤k≤n.
  • Applies to spacing facilities, routers, or sensors along a line.
  • From Ibm interviews; a classic coding interview problem and interview question.

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: