Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Maximum separation M people want to buy houses in a neighborhood. The neighborhood has N vacant houses that are built in a line for
Maximum separation M people want to buy houses in a neighborhood. The neighborhood has N vacant houses that are built in a line for sale. The position of these houses is position[i] with the distance being measured from the entrance gate. All the position[i]'s are distinct. These M people want to live as far away from each other as possible. The distance between two people is measured as position[i]- position[j]. Allot houses to these M people such that the minimum distance among all pairs of people is maximized. The output is the minimum maximized distance. Function description Complete the solve function. This function takes the following 3 parameters and returns the required answer: N: Represents the number of houses M: Represents the number of competitors position: Represents an array of locations of vacant houses Input format for custom testing Note: Use this input format if you are testing against custom input or writing code in a language where we don't provide boilerplate code. The first line contains N denoting the number of houses. The second line contains M denoting the number of competitors. The third line contains an array position denoting the locations of the vacant houses. Output format Print a single integer indicating the minimum maximized distance. Constraints 2 N 105 2 M
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres the Python code that implements the above steps def so...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started