Maximum Team Size
Learn this problemProblem statement
Given n employees, the time when the jth employee starts working is represented by the array startTime[j], and the time when they finish the work is represented by the array endTime[j].
The ith employee can interact with the jth employee if their working hours overlap. A team can only be formed if at least one employee of the team can interact with all other team members.
Determine the maximum size of such a team.
Function
getMaximumTeamSize(startTime: int[], endTime: int[]) → intComplete the function getMaximumTeamSize in the editor with the following parameters:
int startTime[n]: the start times of employees' workint endTime[n]: the end times of employees' work
Returns
int: the maximum possible team size
Examples
Example 1
startTime = [1, 6, 4, 3, 1]endTime = [2, 7, 5, 8, 2]return = 3For this example, n = 5. The source image illustrates the working intervals as follows:
| Employees | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| 4 | o---->o | |||||||
| 3 | o-------------->o | |||||||
| 2 | o---->o | |||||||
| 1 | o---->o | |||||||
| 0 | o---->o | |||||||
Working Hours
Consider the group [1, 2, 3]. Employee 3 can interact with other employees in the group, so a team of size 3 is possible.
A team with more than 3 employees is impossible. Therefore, the answer is 3.