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. 解决Maven项目报错Perhaps you are running on a JRE rather than a JDK?

    问题描述: 在创建SpringMVC项目运行构建项目的时候,发现构建失败.报错信息为Maven-No compiler is provided in this environment. Perhaps ...

  2. python 手动安装模块

    python中 openpyxl是解析 excel 文件的模块,一般使用pip install openpyxl 就可以安装. 但是如果处于公司内网时是无法连网安装的,下面就手动安装进行说明: 1.h ...

  3. Salt常用命令二

    ############################模块############################ 查看模块列表——module salt ‘minion’  sys.list_mo ...

  4. sql plus笔记

    指令请走这边 因为sql plus缓冲区有限 所以要查看输出有时会不太方便 使用spool语句将输出写入文件 sql>spool 要保存的完整路径 ; ; ; sql output; ; ; s ...

  5. tensorflow C++接口调用图像分类pb模型代码

    #include <fstream> #include <utility> #include <Eigen/Core> #include <Eigen/Den ...

  6. Linux--Centos下搭建Git服务器

    参考:http://kimi.it/370.html   http://blog.csdn.net/wave_1102/article/details/47779401 开始直接用 yum insta ...

  7. 创造新时代!谷歌、微软、Facebook等巨头推出全新数据计划的背后

    对于所有互联网企业来说,用户及其数据都是最核心.最根本的宝贵财富.因此,每家互联网企业都不会轻易将自家的数据与别人分享.试想一下,阿里会将淘宝和天猫的数据共享给京东吗?腾讯会把QQ和微信的数据分享给微 ...

  8. 12. docker 网络 docker network (docker 网络)

    1. 环境准备 编写 Vagrantfile 为 # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.require_version "> ...

  9. 吴裕雄--天生自然 pythonTensorFlow图形数据处理:windows操作系统安装指定版本的tensorflow

    pip install tensorflow==1.14.0

  10. matlab2016b

    http://www.cnblogs.com/CQBZOIer-zyy/p/5933954.html