1584. Min Cost to Connect All Points
Practice Min Cost to Connect All Points for free on NudgeCode: Medium, Graph pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
points[i] = [x, y] are points on a plane. Connecting two points costs their Manhattan distance, |x1 - x2| + |y1 - y2|. Return the minimum total cost to connect all points so that there is exactly one path between any two of them.
Example
points = [[0,0],[2,2],[3,10],[5,2],[7,0]] -> 20
Constraints
- 1 <= points.length <= 500
- -10^6 <= x, y <= 10^6
- All points are distinct