There is a company which has a CEO and a hierarchy of employees. All employees have a unique ID, name, and a pointer to their manager and their reports.
Please implement the whoIsOurBoss() method to find the closest manager for two given employees (i.e. the manager farthest from the CEO that both employees report up to).
This is a Lowest Common Ancestor problem on a company hierarchy tree. Given two employees, the task is to return their closest shared manager, meaning the common ancestor farthest from the CEO. A typical solution is to trace each employee’s chain of managers to the CEO, align their depths, and move upward together until the first common node is found. The key idea is recognizing the organization chart as a rooted tree.