Amazon VO 面试真题解析:Employee Directory Structure 员工管理与直属汇报关系

18次阅读
没有评论

Create an employee directory structure that stores employee information for a company. Include manager direct reports.

Implement the following functions:

  • AddEmployee
    • Adds an employee to the company directory
  • RemoveEmployee
    • Removes an employee from the company directory
  • GetDirectReports
    • Returns a list of the direct reports for a given manager
  • GetEmployee
    • Returns the employee information

这道题要求设计一个员工目录结构,核心是同时维护“员工信息”和“上下级关系”。实现时通常会用哈希表按员工 ID 快速定位员工对象,并在员工对象中保存经理引用、直属下属列表等信息,这样 AddEmployee、RemoveEmployee、GetEmployee 和 GetDirectReports 都能高效完成。删除员工时要特别注意同步更新其经理的下属列表,以及必要时处理直属汇报关系的重连或清理,是这类公司组织结构题的关键。

正文完
 0