Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Minimize Manhattan Distances

XPChallenge Points: 30
levelLevel: Hard

You are given an array points representing integer coordinates of some points on a 2D plane,
where each point is given as points[i] = [xi, yi].

The Manhattan distance between two points
(x1, y1) and (x2, y2) is defined as:

|x1 - x2| + |y1 - y2|

You must remove exactly one point from the array such that
the maximum Manhattan distance between any two remaining points
is minimized.

Return the minimum possible value of that maximum distance.

Example 1:

Input: points = [[3,10],[5,15],[10,2],[4,4]]

Output: 12

Explanation:

Explanation: After removing each point, the maximum distances are: Removed Point Max Distance Points Responsible [3,10] 18 (5,15) & (10,2) [5,15] 15 (3,10) & (10,2) [10,2] 12 (5,15) & (4,4) [4,4] 18 (5,15) & (10,2) The minimum possible maximum distance is 12.

Example 2:

Input: points = [[1,1],[1,1],[1,1]]

Output: 0

Explanation:

All points are identical, so removing any point keeps all pairwise distances 0.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result