Arrays-Aggressive Cows what to do?

Didnt understand what to do in it how i can find largest minimum distance

We need to maximize the gap between two adjacent cows kept in the barn that is we need to maximize the minimum possible distance between all pairs of cows.

For example consider the sample input: Number of barns = 5
1 2 8 4 9
Number of cows = 3
The answer here is 3.

As the farmer can put his 3 cows in the stalls at positions 1, 4 and 8,
resulting in a minimum distance of 3 among 3(4-1),4(8-4) being the adjacent distances among the 3 positions.
apply binary search on the search space (min possible space between cows, to max possible space between cows). This gives you low and high, now calculate mid and decide according in binary search if the value of mid is feasible or not

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.