Discussion about JAVA Programming
130 subscribers
10 photos
2 videos
152 files
12 links
Java + DSA Practices ( Daily Fever ) 😎
Daily Mission - 1 question per day
Download Telegram
Today's problem ❓❔
.Assign stalls to K cows to maximize the minimum distance between them
Given a sorted array arr[] consisting of N integers which denote the position of a stall. You are also given an integer K which denotes the number of aggressive cows. You are given the task of assigning stalls to K cows such that the minimum distance between any two of them is the maximum possible.

Examples:

Input: N = 5, K = 3, arr[] = {1, 2, 4, 8, 9}
Output: 3
Explanation: We can place cow 1 at position 1, cow 2 at position 4 and cow 3 at position 9. So, the maximum possible minimum distance between two cows is 3.

Input: N = 6, K = 4, arr[] = {6, 7, 9, 11, 13, 15}
Output: 2
Explanation: We can place cow 1 at position 6, cow 2 at position 9 and cow 4 at position 15. So, the maximum possible minimum distance between two cows is 2.
Solution 🎯
Today's 5 Questions 🎯
Today's 5 Questions 🎯
Today's 5 Questions 🎯