Given an array of length ‘N’, where each element denotes the position of a stall. Now you have ‘N’ stalls and an integer ‘K’ which denotes the number of cows that are aggressive. To prevent the cows from hurting each other, you need to assign the cows to the stalls, such that the minimum distance between any two of them is as large as possible. Return the largest minimum distance.
Example :
array: 1,2,4,8,9 & k=3
O/P: 3
Explaination: 1st cow at stall 1 , 2nd cow at stall 4 and 3rd cow at stall 8
Given an array of length ‘N’, where each element denotes the position of a stall. Now you have ‘N’ stalls and an integer ‘K’ which denotes the number of cows that are aggressive. To prevent the cows from hurting each other, you need to assign the cows to the stalls, such that the minimum distance between any two of them is as large as possible. Return the largest minimum distance.![7ae5c21f-0f67-4fc2-93f9-d14ddb58c390_1624870922 4469664](https://user-images.githubusercontent.com/77771850/200557199-cadaec80-9464-450c-85cb-5cfb0549edef.png)
Example :
array: 1,2,4,8,9 & k=3 O/P: 3 Explaination: 1st cow at stall 1 , 2nd cow at stall 4 and 3rd cow at stall 8