I got this question yesterday in my Google Interview:
Given below are the employees in a Company. The direct reportees of the employees are given along with the inform time required for the news to be transferred from the manager to the reportees.
The task is to find the minimum time in which the news can spread from top level to all the employees in the Company.
“1” -> {“2”: 1, “3”: 2}
“2” → {“4”: 2, “5”: 1}
“5” → {“6”: 1, “7”: 3, “8”: 2}
“3” → {}
“4” → {}
“6” → {}
“7” → {}
“8” → {}
Answer = 5
I was also asked to find the head of the Company unlike the one given in the Leetcode question
Similar Leetcode Problem: https://leetcode.com/problems/time-needed-to-inform-all-employees/
P.S: I saw this question earlier and I was brimming with confidence while trying to solve it but Universe had some other plans.My internet stopped working in between and they had to reschedule my interview..