Meeting Rooms II-LintCode

Getting wrong answer
code link:-https://www.lintcode.com/problem/meeting-rooms-ii/description

Hey @Bhawna
share ur code in Ide

https://ide.geeksforgeeks.org/avKTOlHSD6
I forgot to send code

Hey @Bhawna
Your logic is incoorect this is not an activity selection problem

Try your code on this
2
1 2
2 3

4
1 3
2 4
5 8
6 9

So u need to find maximum overlapping intervals at any point of time.
hey

so basically we have to find min no of roomss so that no meeting collide == max no of meetings happening at any time

say we take a variable counter to keep track of meetings

so initially no meeting at rooms so counter =0;

now we have start and end time of meetings

we will put them all in a vector where each entry in vector is pair st {Time, start or end}

where pair first will give value of time and second will tell wheter its ending time or starting time

sort these vector on the basis of time and now traverse this vector

if meeting start add 1 to counter and if meeting ends then deduct 1 from counter

so our ans will be max value of counter obtained during traversing of the vector

see this for more clarification

start[] = {9:00, 9:40, 9:50, 11:00, 15:00, 18:00}
end[] = {9:10, 12:00, 11:20, 11:30, 19:00, 20:00}

All events sorted by time.
Total roomss at any time can be obtained by subtracting total
meetings ended from total meeetings started by that time.
Time Event Type Total roomss Needed at this Time
9:00 start 1
9:10 end 0
9:40 start 1
9:50 start 2
11:00 start 3
11:20 end 2
11:30 end 1
12:00 end 0
15:00 start 1
18:00 start 2
19:00 end 1
20:00 end 0

Minimum roomss nrequired = Maximum metings at any time
= 3

Got it thanks…

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.