Magnetic Force Between Two Balls
mediumPlace m balls in baskets to maximize minimum distance
Magnetic Force Between Two Balls
Key Insight
Binary search minimum distance and greedily place balls whenever spacing is large enough.
Step 1Sort and Search
Greedy placement check
L
1
02
13
24
37
4Search space: [1..6]
Positions [1, 2, 3, 4, 7], m=3. Search distance from 1..6.
1 / 3