Learn
Practice
Newsletter
Resources
Mobile
New
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Time Needed to Inform All Employees
Bookmark
Input
Star
Chain
Multiple levels
Custom
n
=
6
,
headID
=
2
,
manager
=
[2, 2, -1, 2, 2, 2]
,
informTime
=
[0, 0, 1, 0, 0, 0]
0
0
1
1
2
2
1
3
3
4
4
5
5
head
0
0
1
1
2
2
1
3
3
4
4
5
5
head
0
0
1
1
2
2
1
3
3
4
4
5
5
head
dfs(0)
informTime = 0
0
0
0
1
1
2
2
1
3
3
4
4
5
5
head
max = max(0,
0
) =
0
0
0
0
1
1
0
2
2
1
3
3
4
4
5
5
head
0
+
0
=
0
memo[1]
0
0
0
1
1
0
2
2
1
3
3
4
4
5
5
head
dfs(3)
informTime = 0
0
0
0
1
1
0
2
2
1
3
3
0
4
4
5
5
head
return
0
0
0
0
1
1
0
2
2
1
3
3
0
4
4
5
5
head
no subordinates
→
max = 0
0
0
0
1
1
0
2
2
1
3
3
0
4
4
0
5
5
head
max = max(0,
dfs(5)
)
0
0
0
1
1
0
2
2
1
3
3
0
4
4
0
5
5
0
head
return
0
0
0
0
1
1
0
2
2
1
1
3
3
0
4
4
0
5
5
0
head
return 1
minute
algo
master
.
io
Step:
Start DFS from the head of the company, employee 2
0 / 35
Input
Star
Chain
Multiple levels
Custom
n
=
6
,
headID
=
2
,
manager
=
[2, 2, -1, 2, 2, 2]
,
informTime
=
[0, 0, 1, 0, 0, 0]
0 / 35
algo
master
.
io
Step:
Start DFS from the head of the company, employee 2