Google | India | Onsite 2
Anonymous User
584

Virtual Onsite 2:-


class Employee{
	String name;
	String dept;
	List<Employee> reports;
}
public int getMinTimeToSendMessageToAllEmployees(List<Employee> employees){
}

I needed to complete this function where we dont know who is CEO/BOSS (root) among the list of emplyees. I got the approach, interviewer was also satisfied but I was not able to come up with the working code in time.
Can someone please post the solution
My approach:-

  1. Create a graph with the help of list of employees
  2. Find out the ceo/boss with the help of indegrees
  3. traverse the graph using BFS and capture the levels
    4.return the level at which we were able to traverse all the employees.
Comments (3)