Union-find and connected groups
Which items share a group with A?
Examples
Worked example
Input
Join A with B, then B with C. D stays alone.
Expected output
A, B, and C
Hints and solution
Hint 1
Write down the starting state and walk through one example by hand.
Reveal worked answer
The first join puts A and B together. The second joins that whole group to C.