You are given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane. Return the minimum cost to make all points connected.
The cost of connecting two points [xi, yi] and [xj, yj] is the Manhattan distance between them: |xi - xj| + |yi - yj|.
You may connect any two points directly. All points must be connected, and there must be no extra connections beyond what is needed - in other words, the result must be a minimum spanning tree.
(0,2)
|
(1,2)---(2,2)
|
(3,2)
|
(3,10)
Input: points = [[0,0],[2,2],[3,10],[5,2],[7,0]] Output: 20 Explanation: Connect the points with total Manhattan distance 20; this is the minimum spanning tree cost.
Input: points = [[3,12],[-2,5],[-4,1]] Output: 18 Explanation: The minimum cost to connect all three points using two edges is 18.
1 <= points.length <= 1000-10^6 <= xi, yi <= 10^6(xi, yi) are distinctpoints = [[0, 0], [2, 2], [3, 10], [5, 2], [7, 0]]