Grokking Graph Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Min Cost to Connect All Points (medium)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [x<sub>i</sub>, y<sub>i</sub>].

The cost of connecting two points [x<sub>i</sub>, y<sub>i</sub>] and [x<sub>i</sub>, y<sub>i</sub>] is the Manhattan distance between them: |x<sub>i</sub> - x<sub>i</sub>| + |y<sub>i</sub> - y<sub>i</sub>|, where |val| denotes the absolute value of val.

Return the `minimum cost

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible