1
var numOfMinutes = function (n, headID, manager, informTime) {2
// Build the tree structure5
// {manager: direct employee}6
for (let i = 0; i < manager.length; i++) {7
// the head of the company does not have a manager19
// [employee, time to inform the head]20
let queue = [[headID, 0]];23
while (queue.length) {24
let [emp, currTime] = queue.shift();25
let children = tree[emp] || [];26
for (let child of children) {27
res = Math.max(res, informTime[emp] + currTime);28
queue.push([child, informTime[emp] + currTime]);