1
# Runtime: 2922 ms (Top 60.17%) | Memory: 79.1 MB (Top 76.18%)3
def minCostConnectPoints(self, points: List[List[int]]) -> int:8
# set to store past points to prevent cycle11
# i == the index of current point14
while len(visited) < len(points):15
# Add all costs from current point to unreached points to min heap16
for j in range(len(points)):17
if j == i or j in visited:19
distance = abs(points[i][0] - points[j][0]) + abs(20
points[i][1] - points[j][1]22
heapq.heappush(heap, (distance, j))24
# Add new min cost edge26
dist, point = heapq.heappop(heap)27
if point not in visited:29
# Add point to visited to prevent cycle