KLA / VO Coding Interview: Company Hierarchy Data Structure

15 Views
No Comments

There are three companies: IBM, Intel, and Apple. A total of 8 people worked in these three companies.

Each person can be either a manager or a direct report to a manager.

Produce a class hierarchy diagram of a data structure to manage this information and their relationships.

The data structure should be able to support:

  • A static Company.Print() method to print the information, first iterating through the list of companies, printing out the company name, all their employees’names, social security ID, title, and the name of their direct reports or manager.
  • Then create a list of distinct individuals and print out their names.

This problem is about object-oriented modeling and hierarchical relationship design. You need to model companies, people, and reporting relationships so the structure can represent both company membership and manager-direct-report links without duplicating individuals. A clean solution usually separates personal identity, job/title data, and hierarchy edges, then uses maps or sets to manage companies and a distinct-person list. The main challenge is designing the data structure so it can print company-by-company details and also produce a de-duplicated list of all individuals.

END
 0