Find minimum number of rooms required
I know that my approach may not add much value, but I would like to share it with you.

Detecting room hours overlapping with this logic is correct, but it is hard to read and understand:-

if (lectureInterval[0] &gt; reserved[0] &amp;&amp; lectureInterval[0] &lt; reserved[1]) roomBusyInLectureHours = true;
if (lectureInterval[1] &gt; reserved[0] &amp;&amp; lectureInterval[1] &lt; reserved[1]) roomBusyInLectureHours = true;
if (reserved[0] &gt; lectureInterval[0] &amp;&amp; reserved[0] &lt; lectureInterval[1]) roomBusyInLectureHours = true;
if (reserved[1] &gt; lectureInterval[0] &amp;&amp; reserved[1] &lt; lectureInterval[1]) roomBusyInLectureHours = true;


I think following the approach below will make it more readable and understandable:-

let [reservedStart, reservedEnd] = reserved, [lectureStart, lectureEnd] = lectureInterval;
let busyHours = [...new Array(reservedEnd - reservedStart)].map((v, i)=&gt; reservedStart+i);
let lectureHours = [...new Array(lectureEnd - lectureStart)].map((v, i)=&gt; lectureStart+i);
roomBusyInLectureHours = busyHours.filter(hour =&gt; lectureHours.includes(hour)).length &gt; 0;