Validate a parent-child forest
Given a list of parent-child pairs, decide whether they form a valid forest: no node has two parents, there are no cycles, and every tree has one root. Return the reason when it is not valid.
No answer yet. Write the first one; the best answer gets endorsed.