Given two nodes ("rabbits") in a forest/graph of ancestor relationships, determine whether they share a common ancestor (i.e., belong to the same connected component / have the same root).
Asked in the phone_screen stage. Reconstructed from commenter replies, which mention union-find and LCA framing; OP did not paste the literal question text, likely because it was an embedded image not captured by the page scrape.
Implement share_common_ancestor(parent, rabbit_a, rabbit_b). parent maps each non-root node to its immediate parent; roots are absent as keys. Return True if both rabbits reach the same root, otherwise False.
def share_common_ancestor(parent, rabbit_a, rabbit_b):