Imagine you're a city planner tasked with placing k emergency stations on the perimeter of a square city block to maximize safety coverage. You want to ensure that the closest distance between any two stations is as large as possible.
Given a square with side length side and corners at (0, 0), (0, side), (side, 0), and (side, side), you have a list of candidate locations points on the boundary where stations can be placed. Each point is represented as [x, y].
Your goal is to select exactly k points from the available locations such that the minimum Manhattan distance between any two selected points is maximized.
The Manhattan distance between two points (x₁, y₁) and (x₂, y₂) is |x₁ - x₂| + |y₁ - y₂|.
Return the maximum possible minimum Manhattan distance between the selected k points.
Input & Output
Constraints
- 1 ≤ side ≤ 109
- 2 ≤ k ≤ points.length ≤ 105
- points[i] is on the boundary of the square
- All points are distinct and lie exactly on the square's perimeter