The onsite interview process consisted of four rounds covering coding, ML fundamentals, applied machine learning, and ML system design. Each round started with approximately 10 minutes of values-related and project questions, including how I use AI in my daily work and how I handle competing priorities.
The coding interview involved a tree traversal problem called Print Employee Org Chart. I was given a collection of employee records and asked to generate a hierarchical text representation of the company's organizational structure. Each employee is represented by three strings:
employee_id: A unique identifier for the employee.
manager_id: The identifier of the employee's direct manager.
name: The employee's name.
The company has exactly one CEO, identified by the special condition: employee_id == manager_id. Every other employee reports to exactly one manager. The input records can appear in any order, so the implementation cannot assume that managers are listed before their direct reports.
Implement a function that generates an organization chart as a single formatted string. The output must satisfy the following requirements:
Every employee's name appears on a separate line.
Direct reports appear underneath their managers.
Each level of the hierarchy adds exactly four hyphens (----) of indentation.
The CEO appears at the top without indentation.
Employee names are separated by newline characters (\n).
The final employee's name is not followed by an additional newline.
Constraints
Exactly one CEO exists.
Every other employee has exactly one direct manager.
Morgan is the CEO because their manager ID matches their employee ID. Taylor and Riley report directly to Morgan. Jordan reports to Taylor, while Casey and Parker report to Jordan. Avery reports to Casey. Each additional management level increases the indentation by four hyphens.