Problem
You get points on a 2D plane, each [x, y]. Connecting two points costs their Manhattan distance, |x1 - x2| + |y1 - y2|. Return the minimum total cost to connect all the points, where connected means there is exactly one simple path between any two of them.
Example 1
- Input
- points = [[0, 0], [2, 2], [3, 10], [5, 2], [7, 0]]
- Output
- 20
Example 2
- Input
- points = [[3, 12], [-2, 5], [-4, 1]]
- Output
- 18
Example 3
- Input
- points = [[0, 0]]
- Output
- 0
Constraints
1 <= points.length <= 1000-10^6 <= x, y <= 10^6All points are distinct