Minimum Meeting Rooms

Write the code, see it run, pass the checks.

The problem

  • medium
  • Code

Write minRooms(meetings): each meeting is a [start, end] pair of whole numbers with start less than end, and it needs a room from start up to, but not including, end, so a meeting ending at 10 frees its room for one starting at 10. The meetings come in any order. Return the fewest rooms that hold them all, or 0 if there are none. Don't change meetings. For example, minRooms([[0, 30], [5, 10], [15, 20]]) is 2. The checks include 100,000 meetings, so comparing every pair is too slow.

Your code must pass

  • Counts the rooms for a few meetings
  • Reuses a room when one meeting ends as another starts
  • Returns 0 for no meetings and 1 for one
  • Leaves meetings unchanged
  • Is fast enough for 100,000 meetings