Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up
Problem Submissions Solution

Aggressive Cows

Difficulty: Medium

Acceptance: 70.00%

Points: 30.00

You are given an array of integers stalls[] representing the positions of stalls on a number line and an integer k representing the number of cows. Your task is to place the cows in these stalls such that the minimum distance between any two cows is as large as possible. Each stall can hold only one cow. Return the maximum possible minimum distance between any two cows.

Topics

Companies

Articles

Examples:

N/A

Constraints:
  • 2 = stalls.length = 105
  • 1 = stalls[i] = 10?
  • 2 = k = stalls.length
Companies:
Walmart
Topics:
Binary Search
Locked Content
Access Restricted: Please Login to access the code editor and test cases.