Z55

Magnetic Force Between Two Balls

Staff / Principal Engineer
Target Time: 40 - 50 Minutes
Type: NUMERIC

Problem Statement & Objective

In an array of basket positions, distribute m balls such that the minimum magnetic force between any two balls is maximized.

Function Signature (Python)

max_distance_balls(positions: list[int], m: int) -> int

Input & Output Contract

Output Rule:Maksimum minimum mesafe tam sayısı.

System Constraints

2 <= konumlar.length <= 10^5
1 <= konumlar[i] <= 10^9
Tüm konumlar benzersizdir
2 <= m <= konumlar.length

Example Execution Walkthrough

konumlar = [1, 2, 3, 4, 7], m = 3
1, 4 ve 7 konumlarına koyulursa min mesafe 3 olur -> cevap: 3

Example Test Scenarios (3)

Example 1
Input:[[1,2,3,4,7],3]
Expected Output:3
Example 2: Uçlar
Input:[[5,4,3,2,1,1000000000],2]
Expected Output:999999999
Example 3: İki Top
Input:[[1,10],2]
Expected Output:9
Loading Python Editor...
Input Parameters
[
  [
    1,
    2,
    3,
    4,
    7
  ],
  3
]
Expected Output
3