Aggressive Cows

Given an array stalls of distinct stall positions and the number of cows cows, place every cow in a different stall so that the smallest distance between any…

Given an array `stalls` of distinct stall positions and the number of cows `cows`, place every cow in a different stall so that the smallest distance between any two cows is as large as possible. Return that largest possible smallest distance. The stall positions may be given in any order, not necessarily sorted.

- `2 <= stalls.length <= 100` - `2 <= cows <= stalls.length` - `-10^9 <= stalls[i] <= 10^9` - All stall positions are distinct.

Example 1: input stalls = [1,2,4,8,9], cows = 3; output 3. Place cows at 1, 4, and 8 or 9. A minimum distance of 4 is impossible.

Example 2: input stalls = [10,1,2,7,5], cows = 3; output 4. After sorting, positions 1, 5, and 10 achieve minimum distance 4.

Category: Binary Search. Topic: binary-search. Difficulty: Medium. Patterns: binary-search-on-answer, greedy.