Amazon | Interview question, root of largest tree in a forest

Anonymous User
1444
May 12, 2021
May 12, 2021

Given a forest(one or more disconnected trees ), find the root of the largest tree
i/p: child -> parent relationship. The key is the child and value is the corresponding tree.  
{{1 -> 2}, {3->4}}
o/p:
2(since 2 is less than 4)

Comments (1)