FastPrepAggressive Cows
Problems/Aggressive Cows

Aggressive Cows

PeopleStrong logoPeopleStrong● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a PeopleStrong online assessment. The report names Aggressive Cows. The goal of making the smallest distance as large as possible stays. We chose the function signature, the rule that positions are distinct, and the limits. Our version is about 95% the same as the reported question.

There are stalls at the distinct integer positions in stalls. Place k cows into different stalls so that the minimum distance between any two placed cows is as large as possible. Return that largest achievable minimum distance.

For this exercise, assume at least two cows must be placed, and the positions may arrive unsorted. Distances are measured along the one-dimensional line.

Function

maximumMinimumDistance(stalls: int[], k: int) → int

Examples

Example 1

stalls = [1,2,4,8,9]k = 3return = 3

Place cows at 1,4 and 8. The neighboring distances are 3 and 4, so the minimum is 3; a minimum of 4 is impossible.

Example 2

stalls = [15,0,10,5]k = 2return = 15

With two cows, choose the two extreme stalls 0 and 15.

Constraints

  • For this exercise, assume 2 <= stalls.length <= 20000.
  • 2 <= k <= stalls.length.
  • Stall positions are distinct integers in [0,10^9].

More PeopleStrong interview questions

  • Reverse Linked-List Nodes in Groups of KOA · PHONE SCREEN · Seen Mar 2026
  • Unique Paths Through a GridOA · Seen Mar 2026
  • Shortest Path in an Unweighted GraphOA · Seen Oct 2021
  • Total Set Bits from 1 to NOA · Seen Oct 2021
  • Swap Two Array ElementsOA · Seen Sep 2021
  • Minimum Travel Time with Flashing Traffic LightsOA · Seen Aug 2021
  • Permutation in a StringOA · Seen Aug 2021
  • Rat in a Maze: All Simple PathsOA · Seen Aug 2021
  • Add Two Binary StringsONSITE INTERVIEW · Seen Mar 2026
  • Four SumONSITE INTERVIEW · Seen Mar 2026

Similar questions at other companies

  • Minimize Maximum Group DifferenceDRW · OADRW interview questions
  • Minimum-Cost Solar Rooftop AllocationDeloitte · OADeloitte interview questions
  • Maximize Number of Produced CarsMicrosoft · OAMicrosoft interview questions
  • Spread Cows Across StallsExpedia · OAExpedia interview questions
  • Aggressive CowsAmazon · PHONE SCREEN
  • Maximize the Minimum Cone DistanceSumo Logic · PHONE SCREEN
  • Maximize Fish over Limited HoursByteDance · PHONE SCREENByteDance interview questions
  • Find Minimum TimeAlphaSense · OA
  • Find Minimum TimeBlackRock · OABlackRock interview questions
  • Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions

Interview reports that mention this question

  • PeopleStrong SDE OA and Interview Questions: 12 Experiences
All PeopleStrong interview questionsSee PeopleStrong hiring insights
Saved
class Solution {
    public int maximumMinimumDistance(int[] stalls, int k) {
        // Write your solution here.
    }
}
Checking account…