def countComponents1(n: int, edges: list[list[int]]) -> int:
    """
    quick find based implemenation

    Args:
        n (int): number of nodes
        edges (list[list[int]]): list of edges

    Returns:
        int: number of connected components
    """
    connections = [n for n in range(n)]

    for edge in edges:
        left, right = edge[0], edge[1]

        if connections[left] != connections[right]:

            old_group = connections[right]
            connections[right] = connections[left]

            for index in range(n):
                if connections[index] == old_group:
                    connections[index] = connections[left]

    return len(set(connections))