A company has n employees, uniquely identified with IDs from n - 1. The head of the company has the ID headID.
Each employee i has a direct manager specified by manager[i]. The head of the company has no manager, so manager[headID] is equal to headID.
When an employee receives urgent news, they will inform all of their direct subordinates simultaneously. The time it takes for employee i to inform all of their direct subordinates is informTime[i] minutes.
Given n, headID, manager, and informTime, return the total number of minutes needed to inform all employees in the company.
Constraints:
n
headID n
manager.length n
manager[i] n for all i where i headID
manager[headID]
informTime.length n
informTime[i]
informTime[i] i has no subordinates.
It is guaranteed that all employees can be informed.
A company has n employees, uniquely identified with IDs from n - 1. The head of the company has the ID headID.
Each employee i has a direct manager specified by manager[i]. The head of the company has no manager, so manager[headID] is equal to headID.
When an employee receives urgent news, they will inform all of their direct subordinates simultaneously. The time it takes for employee i to inform all of their direct subordinates is informTime[i] minutes.
Given n, headID, manager, and informTime, return the total number of minutes needed to inform all employees in the company.
Constraints:
n
headID n
manager.length n
manager[i] n for all i where i headID
manager[headID]
informTime.length n
informTime[i]
informTime[i] i has no subordinates.
It is guaranteed that all employees can be informed.