Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of conference rooms required.

Example 1:

Input: [[0, 30],[5, 10],[15, 20]]
Output: 2

Example 2:

Input: [[7,10],[2,4]]
Output: 1

NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

class Solution {
public int minMeetingRooms(int[][] intervals) {
if (intervals == null || intervals.length == 0) {
return 0;
}
int res = 0;
// need to keep track to current end is
int end = 0;
int[] starts = new int[intervals.length];
int[] ends = new int[intervals.length];
for (int i = 0; i < intervals.length; i++) {
starts[i] = intervals[i][0];
ends[i] = intervals[i][1];
}
Arrays.sort(starts);
Arrays.sort(ends); for (int i = 0; i < intervals.length; i++) {
if (starts[i] < ends[end]) {
res += 1;
} else {
end += 1;
}
}
return res;
}
}

[LC] 253. Meeting Rooms II的更多相关文章

  1. [LeetCode] 253. Meeting Rooms II 会议室之二

    Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...

  2. [LeetCode] 253. Meeting Rooms II 会议室 II

    Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...

  3. 253. Meeting Rooms II 需要多少间会议室

    [抄题]: Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],.. ...

  4. 253. Meeting Rooms II

    题目: Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] ...

  5. [LeetCode#253] Meeting Rooms II

    Problem: Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2] ...

  6. [leetcode]253. Meeting Rooms II 会议室II

    Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...

  7. 【LeetCode】253. Meeting Rooms II 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 排序+堆 日期 题目地址:https://leetco ...

  8. [LeetCode] Meeting Rooms II 会议室之二

    Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...

  9. LeetCode Meeting Rooms II

    原题链接在这里:https://leetcode.com/problems/meeting-rooms-ii/ Given an array of meeting time intervals con ...

随机推荐

  1. 跟踪LinkedList源码,通过分析双向链表实现原理,自定义一个双向链表

    1.LinkedList实现的基本原理 LinkedList是一个双向链表,它主要有两个表示头尾节点的成员变量first  .last,因其有头尾两个节点,所以从头或从尾操作数据都非常容易快捷.Lin ...

  2. iPhone到底能不能充一整夜电?

    其实在国内,手机充电一直是个"玄学问题".早在多年前就有大神向小白敦敦教导,"新买的手机要将电用完,并充12个小时,如此反复三次才能延长手机电池寿命".甚至直到 ...

  3. 虚拟机virtualBox

    在笔记本了装了一个虚拟机, 并安装了Linux系统, 方便测试linux 命令. 考虑到不需要图形界面, 学习了用命令行操作虚拟机, 配置如下 linux 下安装openssh-server 虚拟机设 ...

  4. P3810 【模板】三维偏序(陌上花开)(CDQ分治)

    题目背景 这是一道模板题 可以使用bitset,CDQ分治,K-DTree等方式解决. 题目描述 有 nn 个元素,第 ii 个元素有 a_iai​.b_ibi​.c_ici​ 三个属性,设 f(i) ...

  5. ZJNU 1223 - 素数距离——高级

    因为最大可以达到int极限 明显直接筛选不可能完成 所以从其因子入手 因为任何不是素数的数都有除了1与其自身之外的因子 因此,我们筛出2^(31/2)≍46350之内的所有素数,以其作为因子再将题目给 ...

  6. AtCoder Beginner Contest 129

    ABCD 签到(A.B.C过水已隐藏) #include<bits/stdc++.h> using namespace std; ; int n,m,ans,f1[N][N],f2[N][ ...

  7. CSP2019爆零记

    Upd:2019.10.19 初赛 Day 0 CSP-S膜你赛(然而只考一个小时xs) 写(xia)完(xie)有51.5 很虚,很慌 不过CSP-J的模拟有90?(所以CSP-S模拟的码风怎么这么 ...

  8. git的基础使用

    GIT """ 什么是git:版本控制器 - 控制的对象是开发的项目代码 代码开发时间轴:需求1 > 版本库1 > 需求2 > 版本库2 > 版本 ...

  9. POJ-2349 Arctic Network(最小生成树+减免路径)

    http://poj.org/problem?id=2349 Description The Department of National Defence (DND) wishes to connec ...

  10. 一、Cookie和Session介绍

    会话跟踪 1. 什么是会话  * 用户拨打10086,从服务台接通后会话开始:  * 用户发出话费查询请求,服务台响应.这是该会话中的一个请求:  * 用户发出套餐变更请求,服务台响应.这是该会话中的 ...