class Solution:
def numOfMinutes(self, n: int, head_id: int, managers: List[int], inform_time: List[int]) -> int:
def dfs(employee_id: int) -> int:
max_time = 0
for subordinate in graph[employee_id]:
max_time = max(max_time, dfs(subordinate) + inform_time[employee_id])
return max_time
graph = collections.defaultdict(list)
for i, mng_id in enumerate(managers):
if mng_id != -1:
graph[mng_id].append(i)
return dfs(head_id)