Meeting Room - Miscellaneous / Interval

another way that might be much simpler:

def meeting_rooms(intervals: List[List[int]]) → bool:

for i in range(len(intervals)-1):
    if intervals[i][1]>intervals[i+1][0]:
        return False
return True

Given the test cases, if you don’t check for equality (e.g. interval1[1] <= interval2[0]), it’s going to pass. Add a test case for when one meeting has the same end time as the start time for another meeting, and make sure that this is clear in the problem description, that if you two meetings have matching (but not overlapping) start/end times, this would return false.

I think it should still return True cause it is not overlapping time slots and they can still attend both meetings back to back.

this is my solution as well.

Using a heap:

function meetingRooms(intervals) {
    const heap = new Array(intervals.length).fill(null);
    heap[0] = intervals[0];
    for(let i = 1; i < intervals.length; i++) {
        let root = 0;
        while(heap[root]) {
              if(intervals[i][0] < heap[root][0]) {
                  if(intervals[i][1] > heap[root][0]) return false;
                  const temp = intervals[i];
                  intervals[i] = heap[root];
                  heap[root] = temp;
                  root = 2 * root + 1;
              } else {
                  if(heap[root][1] > intervals[i][0]) return false;
                  root = 2 * root + 2;
        heap[root] = intervals[i];
    return true;