给你一个会议时间安排的数组 intervals
,每个会议时间都会包括开始和结束的时间 intervals[i] = [starti, endi]
,返回 所需会议室的最小数量 。
示例 1:
输入:intervals = [[0,30],[5,10],[15,20]] 输出:2
示例 2:
输入:intervals = [[7,10],[2,4]] 输出:1
提示:
1 <= intervals.length <= 104
0 <= starti < endi <= 106
1 /** 2 * @param {number[][]} intervals 3 * @return {number} 4 */ 5 var minMeetingRooms = function (intervals) { 6 let nums = []; 7 for (let [u, v] of intervals) { 8 nums.push([u, 1]); 9 nums.push([v, -1]); 10 } 11 nums.sort((a, b) => a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]); 12 let ans = 0, cur = 0; 13 for (let [time, e] of nums) { 14 cur += e; 15 ans = Math.max(cur, ans); 16 } 17 return ans; 18 };
标签:10,cur,nums,会议室,II,intervals,let,ans,253 From: https://www.cnblogs.com/icyyyy/p/16886858.html