Algorithm · Goldman Sachs · Medium
Requirements The input is a dictionary whose keys are child node IDs and whose values are their respective parent node IDs; together, these relationships describe a forest containing one or more separate trees. Return the ID of the root belonging to the tree with the greatest number of nodes. When multiple trees have the same largest size, choose the root with the numerically smallest ID. Examples {4: 6, 9: 12} -> 6. This represents two trees (6 <- 4 and 12 <- 9), and each…
Checking your access…