Problem · Array

Maximum Team Size

Learn this problem
MediumExpediaNEW GRADOA

Problem 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[]) → int

Complete the function getMaximumTeamSize in the editor with the following parameters:

  • int startTime[n]: the start times of employees' work
  • int 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 = 3

For this example, n = 5. The source image illustrates the working intervals as follows:

Employees12345678
4o---->o
3o-------------->o
2o---->o
1o---->o
0o---->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.

More Expedia problems

drafts saved locally
public int getMaximumTeamSize(int[] startTime, int[] endTime) {
  // write your code here
}
startTime[1, 6, 4, 3, 1]
endTime[2, 7, 5, 8, 2]
expected3
checking account