July 4th Sale
Limited Time Deal: Unlock all premium questions for over 40% off
$10.42$6.25
10
:
09
:
31
:
25
Back to Dashboard
Org Chart Builder
Medium
A company has a list of employees. Each entry has three strings: [id, manager_id, name]. The CEO is the only employee whose manager_id equals their own id. All other employees report to exactly one manager.
Generate an org chart as a hierarchical text string. Each employee's name appears on its own line, followed by a newline character '\n'. The last employee has no trailing newline. Each level of the hierarchy adds four dashes '----' of indentation relative to the manager's level.
...