adjList
to represent the tree structure of the company.manager
array and for each employee i
, add an edge from manager[i]
to i
in adjList
.maxTime
with the maximum of maxTime
and the accumulated inform time.
b. Recursively call DFS for all subordinates of the current node, adding the current node's inform time to the accumulated time.headID
with an initial time of 0
.maxTime
after the DFS traversal is complete.