253. Meeting Rooms II

Given an array of meeting time intervals intervals where intervals[i] = [starti, endi], return the minimum number of conference rooms required.

Example 1:

Example 2:

Constraints:

  • 1 <= intervals.length <= 104
  • 0 <= starti < endi <= 106

Intuition

We need to be able to find out efficiently if a room is available or not for the current meeting and assign a new room only if none of the assigned rooms is currently free.

[ (1,10), (2,7), (3,19), (8,12), (10,20)]

start timings : 1, 2, 3, 8, 10

end timings : 7, 10, 12, 19, 20

start_pointer on 1st element of start timings and end_pointer on 1st element of end timings.

1 > 7 => No , so assign a new room
2 > 7 => No, so assign a new room
3 > 7 => No, so assign a new room
8 > 7 => Yes, no need to assign new room, just increment end_pointer

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
svalak

Passionate about problem solving; #VoraciousReader #MBTIEnthusiast #LovePsychology