Min Cost to Connect All Points (MST)

Medium · Graphs · about 25 minutes

Asked at Amazon, Google, Microsoft.

Given points[i] = [x, y] on a 2D plane, connecting two points costs their Manhattan distance |x1 - x2| + |y1 - y2|. Return the minimum total cost to connect all points so that every pair is connected by exactly one simple path.

Related guides