[leetcode]252. Meeting Rooms会议室有冲突吗
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings.
Example 1:
Input:[[0,30],[5,10],[15,20]]
Output: false
Example 2:
Input: [[7,10],[2,4]]
Output: true
题目
给定一些区间,判断是否有重合。
还是挺实际的场景,经常在图书馆预定study room的系统,内部也应该是这个逻辑。 当有overlapping的时候,就会报错。

思路
任何一组intervals, 若当前start < 之前end,即出现了overlapping
代码
class Solution {
public boolean canAttendMeetings(Interval[] intervals) {
if(intervals == null || intervals.length==0) return true;
int []start = new int[intervals.length];
int []end = new int[intervals.length];
for(int i = 0; i<intervals.length;i++){
start[i] = intervals[i].start;
end[i] = intervals[i].end;
}
Arrays.sort(start);
Arrays.sort(end);
/* 任何一组intervals, 若当前start < 之前end,即出现了overlapping
| i-1 |
| i |
*/
for(int i = 1; i< start.length; i++){
if(start[i]<end[i-1]) return false;
}
return true;
}
}
[leetcode]252. Meeting Rooms会议室有冲突吗的更多相关文章
- [LeetCode] 252. Meeting Rooms 会议室
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...
- LeetCode 252. Meeting Rooms (会议室)$
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...
- [LeetCode#252] Meeting Rooms
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] Meeting Rooms 会议室
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...
- [LeetCode] 253. Meeting Rooms II 会议室之二
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...
- 252. Meeting Rooms 区间会议室
[抄题]: 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】252. Meeting Rooms 解题报告(C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 排序 日期 题目地址:https://leetcode ...
随机推荐
- css- 范围选择
1.子元素范围选择 举例 .iconList_wr li:nth-child(n + 1):nth-child(-n + 4) { margin-right: 0.6rem; } .iconList_ ...
- The Google File System——论文详解(转)
“Google文件存储系统(GFS)是构建在廉价服务器之上的大型分布式系统.它将服务器故障视为正常现象,通过软件方式自动容错,在保证系统可用性和可靠性同时,大大降低系统成本. GFS是Google整个 ...
- Oracle相关文章
1.oracle 11g常用命令 2.Oracle的在windows下的安装及使用 3.Oracle scott账户被锁定,scott默认密码,sys,system默认密码 4.NaviCat Pri ...
- UNITY优化资料收集
U3D手册: Optimizing garbage collection in Unity games https://zhuanlan.zhihu.com/p/25306993 https://gi ...
- DOM精简版笔记
1.1. 基本概念 1.1.1. DOM DOM Document Object Model 文档对象模型 就是把HTML文档模型化,当作对象来处理 DOM提供的一系列属性和方法可以 ...
- 维护没有源代码的遗留 Java 项目
维护没有源代码的遗留 Java 项目 Give Those Sweets Some Love --> 有时你可能不得不修改一些只有 Jar 和 .class 的 Java 项目. 要修改 Jar ...
- ArcGIS 10安装及破解
1.下载 ArcGIS 10 安装程序及破解文件后面提供电驴的下载地址(可以使用迅雷.QQ旋风等下载工具下载),下载文件是一个光盘镜像文件:? ArcGIS_Desktop10_122519.iso. ...
- C# HttpWebRequest 模拟下载
C# web 获取服务端cookie 原文地址:https://www.cnblogs.com/louby/p/5569536.html C#多线程环境下调用 HttpWebRequest 并发连接限 ...
- windows 允许空密码登陆
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa 这个注册表键值下的limitblankpassworduse项 修改为0或者1
- linux下各权限的细分
PS:有时候你发现用root权限都不能修改某个文件,大部分原因是曾经用chattr命令锁定该文件了.chattr命令的作用很大,其中一些功能是由Linux内核版本来支持的,不过现在生产绝大部分跑的li ...