Validate a parent-child forest

0
Remix

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.

WaymoTechnical phone screenLast asked May 2026
No answer yet. Write the first one; the best answer gets endorsed.