Skip to content

Commit f29f0c1

Browse files
committed
Runtime: 742 ms (Top 20.63%) | Memory: 110.7 MB (Top 51.35%)
1 parent 074eb15 commit f29f0c1

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
// Runtime: 742 ms (Top 20.63%) | Memory: 110.7 MB (Top 51.35%)
12
var numOfMinutes = function(n, headID, manager, informTime) {
2-
3-
// Build the tree structure
3+
4+
// Build the tree structure
45
let tree = {}
5-
6-
// {manager: direct employee}
6+
7+
// {manager: direct employee}
78
for (let i = 0 ; i < manager.length ; i++){
8-
// the head of the company does not have a manager
9+
// the head of the company does not have a manager
910
if (i === headID){
1011
continue
1112
}
@@ -16,12 +17,11 @@ var numOfMinutes = function(n, headID, manager, informTime) {
1617
tree[m].push(i)
1718
}
1819

19-
20-
// BFS
21-
// [employee, time to inform the head]
20+
// BFS
21+
// [employee, time to inform the head]
2222
let queue = [[headID, 0]]
2323
let res = 0
24-
24+
2525
while (queue.length){
2626
let [emp, currTime] = queue.shift()
2727
let children = tree[emp] || []
@@ -30,6 +30,6 @@ var numOfMinutes = function(n, headID, manager, informTime) {
3030
queue.push([child, informTime[emp] + currTime])
3131
}
3232
}
33-
33+
3434
return res
35-
};
35+
};

0 commit comments

Comments
 (0)