Description
A company has n employees. Given manager relationships and inform times, return total time for head to inform all employees.
Examples
Input:
n = 6, headID = 2, manager = [2,2,-1,2,2,2], informTime = [0,0,1,0,0,0]Output:
1Explanation:
Head informs all in 1 unit.
Input:
n = 6, headID = 2, manager = [1], informTime = [1]Output:
1Explanation:
Edge case with a single-element array.
Input:
n = 7, headID = 3, manager = [1,1,0,1,-1,2,2], informTime = [0,0,0,4,0,1,1]Output:
6Explanation:
Employee 3 (head) informs subordinate 1 in 4 minutes. Employee 1 informs employees 0 and 2. Employee 2 then informs employees 5 and 6, each taking additional time. The longest notification chain takes 6 minutes total.
Constraints
- •
1 ≤ n ≤ 10⁵