position
array in ascending order.start
to 1 and end
to the difference between the last and first positions in the sorted array.start
is less than or equal to end
:
a. Calculate mid
as the average of start
and end
.
b. Check if it's possible to place m
balls with at least mid
distance apart using a helper function.
c. If it's possible, update start
to mid + 1
and set result
to mid
(potential answer).
d. If it's not possible, update end
to mid - 1
.result
as the maximum minimum distance.