CULPRO-Editorial

Problem Links

Practice
Contest

Difficulty

Easy

PREREQUISITES

Ad hoc

PROBLEM

Given the entry and exit times of different people to a party, we need to find the maximum number of people present during the whole party.

EXPLANATION

The problem simply asks us to calculate the maximum number of people present during the whole party.

Let start[] and end[] be two sorted arrays where start[i] and end[i] denote the entry time, i <=n, where N is the number of exits and the entries recorded.

We can maintain a counter, which we can increase whenever we encounter an entry and decrease that counter whenever we encounter an exit. At every step we can compare the number of people with the maximum number of people found till now.

EDITORIALIST’S SOLUTION

Editorialist’s Solution