Maximize the Minimum Cone Distance
Updated
Problem statement
You are given n distinct coordinates in the integer array positions. Choose exactly m coordinates at which to place cones.
The distance between two cones is the absolute difference between their coordinates. Return the largest possible value of the minimum distance between every pair of consecutively placed cones after the chosen coordinates are sorted.
Function
maximizeMinimumConeDistance(positions: int[], m: int) → intExamples
Example 1
positions = [1,2,8,4,9]m = 3return = 3Choosing coordinates [1,4,8] gives consecutive gaps 3 and 4, so its minimum gap is 3. No placement has a larger minimum gap.
Example 2
positions = [1,5,8,4,9,12,19]m = 3return = 8Choosing [1,9,19] gives gaps 8 and 10, so the answer is 8.
Constraints
2 <= positions.length <= 6000.2 <= m <= positions.length.0 <= positions[i] <= 10^9.- All coordinates in
positionsare distinct.
Similar questions at other companies
- Aggressive CowsAmazon · PHONE SCREEN
- Maximize Fish over Limited HoursByteDance · PHONE SCREENByteDance interview questions
- Minimize Maximum Group DifferenceDRW · OADRW interview questions
- Minimum-Cost Solar Rooftop AllocationDeloitte · OADeloitte interview questions
- Maximize Number of Produced CarsMicrosoft · OAMicrosoft interview questions
- Aggressive CowsPeopleStrong · OAPeopleStrong interview questions
- Spread Cows Across StallsExpedia · OAExpedia interview questions
- Count Winning Dice Face PairsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Fair Capped Money DistributionGusto · PHONE SCREEN · ONSITE INTERVIEWGusto interview questions
- Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions