meeting room 2 javascript solution
/**
* @param {number[][]} intervals
* @return {number}
*/
const minMeetingRooms = (intervals) => {
let startList = [];
let endList = [];
let endPos = 0;
let rooms = 0;
for (let i = 0; i < intervals.length; i++) {
startList.push(intervals[i][0]);
endList.push(intervals[i][1]);
}
startList.sort((a, b) => a - b);
endList.sort((a, b) => a - b);
for (let i = 0; i < intervals.length; i++) {
if (startList[i] < endList[endPos]) {
rooms++;
} else {
endPos++;
}
}
return rooms;
};
// console.log(minMeetingRooms([[7, 10],[2, 4]]));
// 1
Also in JavaScript:
- Update matched key values in two JavaScript objects
- ORDS GET json case sensitive data keys
- angular pipe multiple arguments
- TypeError: Object of type ndarray is not JSON serializable
- js copy span text to clipboard
- how to get the status of other urls in ajax
- how to control where the text cursor on div
- Javascript get classes list
- chart.js label word wrap
- angular load json file with httpclient
- jquery remove css
- Rendered more hooks than during the previous rende
- how to get started with nodejs
- classList has class
- identify chrome on android using javascript
- javascript class setter
- javascript close window
- javascript array remove last
- circle wave js
- javascript keypress backspace not working
- ejs partial pass value
- angular Property 'value' does not exist on type 'HTMLElement'.
- javascript getters and setters
- javascript array add end