A company has n employees, each assigned a unique ID ranging from 0 to n - 1, with the head of the company identified by headID.
Each employee has a direct manager, as specified in the manager array, where manager[i] indicates the direct manager of the i-th employee, and manager[headID] is set to -1. It is guaranteed that the reporting structure forms a tree.
The head of the company needs to notify all employees about urgent news. He will inform his direct subordinates, who will then pass the information to their own subordinates, continuing this process until everyone is informed.
The i-th employee requires informTime[i] minutes to notify all of his direct reports. This means that after informTime[i] minutes, his subordinates can begin spreading the news.
Return the total number of minutes required to inform all employees about the urgent news.
leetcode
A company has n employees, each assigned a unique ID ranging from 0 to n - 1, with the head of the company identified by headID.
Each employee has a direct manager, as specified in the manager array, where manager[i] indicates the direct manager of the i-th employee, and manager[headID] is set to -1. It is guaranteed that the reporting structure forms a tree.
The head of the company needs to notify all employees about urgent news. He will inform his direct subordinates, who will then pass the information to their own subordinates, continuing this process until everyone is informed.
The i-th employee requires informTime[i] minutes to notify all of his direct reports. This means that after informTime[i] minutes, his subordinates can begin spreading the news.
Return the total number of minutes required to inform all employees about the urgent news.
leetcode