You are given an array arr of size n which denotes the position of stalls. You are also given an integer k which denotes the number of aggressive cows. The task is to assign stalls to k cows such that the minimum distance between any two of them is maximized. Find the maximum possible minimum distance.
6
6 7 9 11 13 15
4
2
We can place cow 1 at position 6, cow 2 at position 9, cow 3 at position 11 and cow 4 at position 15. So, the maximum possible minimum distance between two cows is 2.
5
1 2 8 4 9
3
3
We can place cow 1 at position 1, cow 2 at position 4, cow 3 at position 8. So, the maximum possible minimum distance between two cows is 3.
5
10 1 2 7 5
2
9