Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    3102 - Minimize Manhattan Distances.

    Hard

    You are given a array points representing integer coordinates of some points on a 2D plane, where <code>pointsi = x<sub>i</sub>, y<sub>i</sub></code>.

    The distance between two points is defined as their Manhattan distance.

    Return the minimum possible value for maximum distance between any two points by removing exactly one point.

    Example 1:

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

    Output: 12

    Explanation:

    The maximum distance after removing each point is the following:

    • After removing the 0<sup>th</sup> point the maximum distance is between points (5, 15) and (10, 2), which is |5 - 10| + |15 - 2| = 18.

    • After removing the 1<sup>st</sup> point the maximum distance is between points (3, 10) and (10, 2), which is |3 - 10| + |10 - 2| = 15.

    • After removing the 2<sup>nd</sup> point the maximum distance is between points (5, 15) and (4, 4), which is |5 - 4| + |15 - 4| = 12.

    • After removing the 3<sup>rd</sup> point the maximum distance is between points (5, 15) and (10, 2), which is |5 - 10| + |15 - 2| = 18.

    12 is the minimum possible maximum distance between any two points after removing exactly one point.

    Example 2:

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

    Output: 0

    Explanation:

    Removing any of the points results in the maximum distance between any two points of 0.

    Constraints:

    • <code>3 <= points.length <= 10<sup>5</sup></code>

    • points[i].length == 2

    • <code>1 <= points0, points1<= 10<sup>8</sup></code>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer minimumDistance(Array<IntArray> points)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait