# Min Cost to Connect All Points SOLUTION LEETCODE

Page Contents

### Min Cost to Connect All Points SOLUTION

You are given a cluster focuses speaking to whole number directions of certain focuses on a 2D-plane, where points[i] = [xi, yi].

The expense of associating two focuses [xi, yi] and [xj, yj] is the manhattan separation between them: |xi – xj| + |yi – yj|, where |val| indicates the supreme estimation of val.

Return the base expense to make all focuses associated. All focuses are associated if there is actually one basic way between any two focuses.

Model 1:

Info: focuses = [[0,0],[2,2],[3,10],[5,2],[7,0]]

Yield: 20

Clarification:

We can associate the focuses as appeared above to get the base expense of 20.

Notice that there is a remarkable way between each pair of focuses.

Model 2:

Info: focuses = [[3,12],[-2,5],[-4,1]]

Yield: 18

Model 3:

Info: focuses = [[0,0],[1,1],[1,0],[-1,1]]

Yield: 4

Model 4:

Info: focuses = [[-1000000,- 1000000],[1000000,1000000]]

Yield: 4000000

Model 5:

Info: focuses = [[0,0]]

Yield: 0

Imperatives:

1 <= points.length <= 1000

– 106 <= xi, yi <= 106

All sets (xi, yi) are unmistakable.