Maximize the Minimum Distance Between Robots
Updated
Problem statement
A factory line has candidate robot stations at the distinct integer coordinates in positions. Choose exactly robots stations.
The separation of a placement is the minimum absolute distance between any two selected stations. Return the largest separation that can be achieved.
Function
maximizeMinimumRobotDistance(positions: int[], robots: int) → intExamples
Example 1
positions = [1,2,8,12,17]robots = 3return = 7Stations 1, 8, and 17 give adjacent gaps 7 and 9, so the minimum is 7.
Example 2
positions = [5,9]robots = 2return = 4Both stations must be selected, and their distance is 4.
Example 3
positions = [0,3,4,7,10]robots = 4return = 3Selecting 0, 3, 7, and 10 achieves a minimum gap of 3.
Constraints
2 <= positions.length <= 100000.2 <= robots <= positions.length.0 <= positions[i] <= 10^9.- All positions are distinct.
More Amazon Onsite Interview questions
- LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Maximal SquareONSITE INTERVIEW · Seen Nov 2026
- Serialize and Deserialize a Binary TreeONSITE INTERVIEW · Seen Nov 2026
- Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Diagonal Traversal of a Binary TreeONSITE INTERVIEW · Seen Nov 2026
- Minimum Time to Spread Through a GridPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Optimal Account BalancingONSITE INTERVIEW · Seen Nov 2026
- Task SchedulerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Number of IslandsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 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
- Maximize the Minimum Cone DistanceSumo Logic · PHONE SCREEN
- Aggressive CowsPeopleStrong · OAPeopleStrong interview questions
- Spread Cows Across StallsExpedia · OAExpedia interview questions
- Maximize Fish over Limited HoursByteDance · PHONE SCREENByteDance interview questions
- Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
- Minimum Station Tracks for a Train ScheduleBNSF Railway · ONSITE INTERVIEWBNSF Railway interview questions
Amazon interview experiences
- Amazon Experienced SDE Onsite Questions: 1 Experience
- Amazon SDE Onsite Interview Questions: 9 Experiences
- Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
- Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
- Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
- Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)