Geeksforgeeks

Error

Consider a big party where N guests came to it and a log register for guest’s entry and exit times was maintained. Find the minimum time at which there were maximum guests at the party. Note that entries in the register are not in any order.

**Example 1:**

**Input:
**N = 5
Entry= {1, 2,10, 5, 5}
Exit = {4, 5, 12, 9, 12}
**Output: **3 5
**Explanation: **At time 5 there were
guest number 2, 4 and 5 present.

**Example 2:**

**Input:
**N = 7
Entry= {13, 28, 29, 14, 40, 17, 3}
Exit = {107, 95, 111, 105, 70, 127, 74}
**Output: **7 40
**Explanation: **At time 40 there were
all 7 guests present in the party.

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **findMaxGuests() **which takes 3 arguments(Entry array, Exit array, N) and returns the maximum number of guests present at a particular time and that time as a pair.

**Expected Time Complexity: **O(N*Log(N) ).

**Expected Auxiliary Space: **O(1).

**Constraints:**

1 <= N <= 10^{5}

1 <= Entry[i],Exit[i] <= 10^{5}

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Maximum Intervals Overlap

...