[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 ...
随机推荐
- 虚拟机mac 与主机的网络共享
1. 主机建立共享文件夹 aaa 2.虚拟机采用桥接 3.mac打开Finder 找到 “前往” 连接服务器”输入“smb://192.168.1.xx”(你电脑的ip地址),点击连接.
- C#使用MonoPInvokeCallback,让C直接回调C#函数
Test.mm char* TestMakeCString(NSString *str) { const char* string = [str UTF8String]; if (string == ...
- 【x】 PAT/BasicLevel_C++/1002. 写出这个数 (20).cpp
C++中的to_string()函数[C++11支持] - Bravo Yeung-羊较瘦之自留地 - CSDN博客https://blog.csdn.net/lzuacm/article/detai ...
- English Conversation – Checking in at an airport
English Conversation – Checking in at an airport Share Tweet Share Tagged With: Ben Franklin Exercis ...
- 福州大学软件工程W班-助教总结
背景 福州大学软件工程W班,总人数46人,讲师汪老师. 前期期望 希望自己能够在课程当中起到引导作用,发挥助教最大的用处. 实际执行情况 第一个问题是自动化测试工具,该工具主要是用来测试程序WordC ...
- 限制ssh登录ip和系统用户
一般对于安全性要求比较高的系统,限制ssh登录的源ip地址和可以登录的系统账户是非常有必要的,ssh登录的源地址和可以登录的系统账户的设置在sshd的配置文件/etc/ssh/sshd_config中 ...
- IE (第一部分) 浏览器 中 关于浏览器模式和文本模式的困惑
什么是浏览器模式和文本模式? 经常使用IE开发者工具的同学,肯定见过浏览器模式和文本模式,对于这两个名词,综合相关文档解释如下: 浏览器模式(Browser Mode),用于切换IE针对该网页的默认文 ...
- 推荐几个Adobe Flex Builder 3的插件(代码格式化和fms服务器通讯文件(main.asc)编写)
1.Fms plugins 编写FMS服务器端脚本时,最头疼的莫过于AS1的语法了.习惯了AS2.3后,在没有代码提示的环境下,写代码确实是件很头疼的事,这个插件就可以发挥作用了. Flash Med ...
- platform 系统是windows还是liunx
import platform # 判断当前代码运行的系统是windows还是liunx print(platform.architecture()) print(platform.platform( ...
- 在linux和Mac中访问某个文件夹中所有的文件
在linux和Mac中访问某个文件夹中所有的文件——输出所有的文件名 #include <stdio.h> #include <dirent.h> int main() { s ...