**Problem Description**

Consider a big party where a log register for guest’s entry and exit times is maintained.

You are given two integer **entry[]** and **exit[]** each of size **N** where **(entry[i], exit[i])** denotes the entry and exit time for guest i.

Find the time at which there are maximum guests in the party.

**NOTE:**

- Entries in register are not in any order.
- If there are multiple answer output the smallest one.

1 <= N <= 10^{5}

1 <= entry[i] < exit[i] <= 10^{6}

First argument is an 1D integer array **A** denoting the **entry[]**.

Second argument is an 1D integer array **B** denoting the **exit[]**.

Return a single integer denoting the time at which there are maximum guests in the party.

Input 1:

A = [1, 2, 9, 5, 5] B = [4, 5, 12, 9, 12]

Input 2:

A = [1] B = [3]

Output 1:

5

Output 2:

1

Explanation 1:

The input is like: First guest in array arrives at 1 and leaves at 4,second guest arrives at 2 and leaves at 5, and so on. There are maximum 3 guests at time 5.

Explanation 2:

There is only one guest which arrives at 1 and exists at 3 so the answer can be 1, 2 or 3 but we will output 1(smallest one).

NOTE:You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.

Sign Up

to access hints and editorial solutions for**Maximum Intervals Overlap**

to access hints and editorial solutions for

Loading...