Practice: Min Cost to Connect All Points

Problem: https://leetcode.com/problems/min-cost-to-connect-all-points/

Recognition reminder: you are given points on a plane and may connect any two of them at a cost equal to their Manhattan distance. You want every point joined into one connected whole at the least total cost, with no concern for how long the path between any particular pair turns out to be. “Connect everything as cheaply as possible” is a different question from “shortest path between two nodes”: it is a minimum-spanning-tree question. Note the shape of the graph here, every pair of points is a candidate edge, which makes it dense, and that should inform which spanning-tree method is cleanest.

Before you start (the five-beat rhythm)

  1. Your Pattern Card for this week is already written.
  2. Name the pattern aloud and write your approach as a plain-English comment before any code.
  3. Struggle floor: 25 minutes unaided. No hints, no AI, no Discuss tab.
  4. If stuck past the floor, ask the tutor for a hint. Six rungs, one per ask.
  5. Debrief in your commit message before moving to the next problem.

Your target

Fill these in yourself before you look at anyone else’s solution:

Target time complexity:  ____
Target space complexity: ____

Think about how many candidate edges there are when every pair of n points can be connected, and let that count guide whether you reach for a heap or a plain scan to find the next cheapest edge to add.

Where your code goes

Write your solution in your own work repo (see getting-started.md), not in this folder. This folder ships only the problem spec and a provided-example test (tests/test_provided.py) so you can check the given cases locally before you submit to LeetCode’s judge. The judge is the oracle; the tutor will not confirm your answer by reading it.

Debrief (paste into your commit message)

1. What pattern did this turn out to be?
2. What was the trigger phrase or input shape that should have made me reach for it?
3. What was the time and space complexity, and what would dominate at scale?
4. What edge case would have broken my first attempt?
5. What would I do differently in three days when I see this cold?