FastPrepMaximum Interactive Team Size

Maximum Interactive Team Size

Microsoft logoMicrosoft● MediumINTERNOA
Learn

Problem statement

You are given n employees. Employee i works during the closed interval [startTime[i], endTime[i]].

Two employees can interact when their working intervals overlap. A team is valid when at least one employee in that team can interact with every other team member. The other team members do not need to interact with one another.

Return the maximum possible size of a valid team. An employee is included in their own team, so the answer is at least 1.

Function

getMaximumTeamSize(startTime: int[], endTime: int[]) → int

Examples

Example 1

startTime = [1,6,4,3,1]endTime = [2,7,5,8,2]return = 3

Employees 1, 2, and 3 form a valid team because employee 3, working from 3 through 8, overlaps both other intervals. No employee overlaps enough intervals to form a team of four.

Example 2

startTime = [1,2,3]endTime = [5,4,3]return = 3

All three intervals contain time 3, so any employee can serve as the member who interacts with everyone.

Example 3

startTime = [1,4,7]endTime = [2,5,8]return = 1

No two employees overlap, so every valid team contains only its central employee.

Constraints

  • 1 <= startTime.length == endTime.length <= 200000.
  • 0 <= startTime[i] <= endTime[i] <= 10^9.
  • Intervals that share an endpoint overlap.

More Microsoft problems

See Microsoft hiring insights
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…