Algorithm · Waymo · Medium
Build a manager for a company's reporting structure. Each employee is identified by a distinct eid, and together the employees make up a single rooted tree of reporting lines whose root is the CEO. The FTE score of an employee eid is the size of the subtree rooted at that employee: it counts the employee, everyone who reports to them directly, and everyone who reports to them indirectly. No employee may have more than k direct reports. The manager must handle these…