You are given points on a 2D plane. The cost to connect two points is their Manhattan distance |x₁−x₂| + |y₁−y₂|. Return the minimum total cost to make all points connected (directly or indirectly) — i.e., the weight of a minimum spanning tree.
Input
n 2 — the number of points and the coordinate countx y for each pointOutput: the minimum total cost.
5 2 0 0 2 2 3 10 5 2 7 0
20
Edges (0,0)-(2,2), (2,2)-(5,2), (5,2)-(7,0), (2,2)-(3,10) cost 4+3+4+9.
3 2 3 12 -2 5 -4 1
18
Run your code against the sample tests, or Submit to run the full suite.