FastPrepFastPrep
Problem Brief

Get Max Traffic Time

FULLTIMEOA
See IBM online assessment and hiring insights

There is client/server architecture with n clients and one server. Each client starts its interaction with the server at the second start[i] and stops at the second end[i]. The maximum traffic is defined as the maximum number of concurrent interactions with the server.

Find the earliest time at which the maximum number of clients are interacting with the server.

Note: The endpoint is also included in the interaction.

Function Description

Complete the function getMaxTrafficTime in the editor below.

getMaxTrafficTime has the following parameters:

  1. int start[n]: interaction start times
  2. int end[n]: interaction end times

Returns

int: the earliest time of maximum concurrent interactions

1Example 1

Input
start = [1, 6, 2, 9], end = [7, 8, 6, 10]
Output
6
Explanation
Example 1 illustration

The maximum number of concurrent interactions is 3 which happens first at the 6th second. Return 6.

2Example 2

Input
start = [2, 3, 7, 4, 7], end = [4, 5, 8, 7, 10]
Output
4
Explanation
🐈‍⬛

Constraints

Limits and guarantees your solution can rely on.

  • 1 ≤ n ≤ 10^5
  • 1 ≤ start[i] ≤ end[i] ≤ 10^9
public int getMaxTrafficTime(int[] start, int[] end) {
  // write your code here
}
Input

start

[1, 6, 2, 9]

end

[7, 8, 6, 10]

Output

6

Sign in to submit your solution.