HarshwardhanPatil07 / HactoberFest2024

A Simple😉 beginner friendly😊 Repo for all programmers and coders. All contributors are requested to star🌟this repo and and folllllow me. Contribute to start your journey with hacktoberfest. Happy Hacking💻!!!
MIT License
115 stars 309 forks source link

Aggressive Cows Problem #305

Open its-amans opened 5 days ago

its-amans commented 5 days ago

Problem statement

You are given an 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.

Print the maximum possible minimum distance.

Example: Input: 'n' = 3, 'k' = 2 and 'arr' = {1, 2, 3}

Output: 2

Explanation: The maximum possible minimum distance will be 2 when 2 cows are placed at positions {1, 3}. Here distance between cows is 2.

Constraints : 2 <= 'n' <= 10 ^ 5 2 <= 'k' <= n 0 <= 'arr[i]' <= 10 ^ 9

its-amans commented 5 days ago

Hi @HarshwardhanPatil07 , I want to add a cpp solution under hacktoberfest for this question . Please assign this problem to me

HarshwardhanPatil07 commented 1 day ago

Read the guidelines carefully. make sure you follow and star the repository!