As reported: Goldman Sachs Associate Superday, data structures round (2025): Magnetic Force Between Two Balls.
Baskets are at positions position[i]. Put m balls into distinct baskets so that the minimum distance between any two balls is as large as possible. Return that distance.
This is LeetCode 1552 — Magnetic Force Between Two Balls.
Example 1
position = [1,2,3,4,7], m = 3
-> 3
Example 2
position = [5,4,3,2,1,1000000000], m = 2
-> 999999999
Constraints: 2 ≤ n ≤ 10^5; 1 ≤ position[i] ≤ 10^9, distinct; 2 ≤ m ≤ n.
Code runner format: one JSON value per line: position, then m (LeetCode's test-case format). Implement maxDistance(position, m); the harness prints the result as JSON.