[LC] 253. Meeting Rooms II
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的更多相关文章
- [LeetCode] 253. Meeting Rooms II 会议室之二
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...
- [LeetCode] 253. Meeting Rooms II 会议室 II
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...
- 253. Meeting Rooms II 需要多少间会议室
[抄题]: Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],.. ...
- 253. Meeting Rooms II
题目: Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] ...
- [LeetCode#253] Meeting Rooms II
Problem: Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2] ...
- [leetcode]253. Meeting Rooms II 会议室II
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...
- 【LeetCode】253. Meeting Rooms II 解题报告(C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 排序+堆 日期 题目地址:https://leetco ...
- [LeetCode] Meeting Rooms II 会议室之二
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...
- LeetCode Meeting Rooms II
原题链接在这里:https://leetcode.com/problems/meeting-rooms-ii/ Given an array of meeting time intervals con ...
随机推荐
- java 环境变量配置搭建(1)
基础常识,classPath配置,朱姐,跨平台性,world组成部分
- 前端Json 增加,删除,修改元素(包含json数组处理)
一:基础JSON对象 二:JSON数组数据 以下为增删修改方法: <!DOCTYPE html> <html lang="en"> <head> ...
- Web应用和web.xml文件
1.构建Web应用 手动构建一个Web应用: 在任意的目录小创建一个文件夹,例如webDemo 在第一步创建的文件夹中创建一个WEB-INF文件夹(注意大写); 随意找到一个Web应用,将其中的web ...
- 第7节 Arrays工具类
package cn.itcast.day08.demo04; import java.util.Arrays; /*java.util.Arrays是一个与数组相关的工具类,里面提供了大量静态方法, ...
- Java远程调用Linux脚本
参考:http://blog.csdn.net/xiao_jun_0820/article/details/26254813 http://blog.csdn.net/a19881029/artic ...
- Excel VBA发送Email时自动允许Outlook安全对话框
在Outlook的宏安全性设置如果选择了“为所有宏提供通知” 并且,在[编程访问]中选择了“总是向我发出警告” 在其他VBA中创建邮件过程中,如果修改Recipients或者执行Send方法,都会弹出 ...
- Hibernate(四)--延迟加载(lazyload)
hibernate中的延迟加载(lazyload)分属性的延迟加载和关系的延迟加载 属性的延迟加载: 当使用load的方式来获取对象的时候,只有访问了这个对象的属性,hibernate才会到数据库中进 ...
- 蓝桥杯 K好数(dp)
Description 如果一个自然数N的K进制表示中任意的相邻的两位都不是相邻的数字,那么我们就说这个数是K好数.求L位K进制数中K好数的数目.例如K = 4,L = 2的时候,所有K好数为11.1 ...
- c语言中continue的运用,同时学习接收字符,打印字符,遍历字符
/************************************************************************* > File Name: continue. ...
- 绿洲作业第二周 - 周二music work 音乐
Please kindly find the music work from Ms. Sophie. 1.请跟随附件中老师录制的视频进行学习和练习.(附件有带拼音的乐谱供KS1和外国学生使用) htt ...