Back to problems

Build an Organizational Reporting Forest

Algorithm · Snowflake · Medium

You are given n reporting records. Each record is a pair [employee, manager] stating that employee has manager as their immediate supervisor. Together these records form a company hierarchy that may consist of several separate trees (a forest). Print the entire hierarchy from the top down. A person is a root of a tree if their name shows up as a manager in some record but never as an employee in any record. Every employee has at most one immediate manager, so each person…

Loading the rest of the question…