[LeetCode] 252. Meeting Rooms_Easy tag: Sort
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
基本思路就是O(n^2)的方式, imporve就是O(nlgn) 排序咯.
Code
# Definition for an interval.
# class Interval:
# def __init__(self, s=0, e=0):
# self.start = s
# self.end = e class Solution:
def canAttendMeetings(self, intervals):
"""
:type intervals: List[Interval]
:rtype: bool
"""
intervals.sort(key = lambda x: x.start)
for i in range(1, len(intervals)):
if intervals[i].start < intervals[i-1].end:
return False
return True
[LeetCode] 252. Meeting Rooms_Easy tag: Sort的更多相关文章
- [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]252. Meeting Rooms会议室有冲突吗
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...
- [LeetCode] 455. Assign Cookies_Easy tag: Sort
Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...
- [LeetCode] 506. Relative Ranks_Easy tag: Sort
Given scores of N athletes, find their relative ranks and the people with the top three highest scor ...
- [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] 130. Surrounded Regions_Medium tag: DFS/BFS
Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. A reg ...
- [LeetCode] 415. Add Strings_Easy tag: String
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2 ...
随机推荐
- 分布式实时日志系统(四) 环境搭建之centos 6.4下hbase 1.0.1 分布式集群搭建
一.hbase简介 HBase是一个开源的非关系型分布式数据库(NoSQL),它参考了谷歌的BigTable建模,实现的编程语言为 Java.它是Apache软件基金会的Hadoop项目的一部分,运行 ...
- css笔记 - 张鑫旭css课程笔记之 vertical-align 篇
支持负值的属性: margin letter-spacing word-spacing vertical-align 元素vertical-align垂直对齐的位置与前后元素都没有关系元素vertic ...
- angularjs结合html5的拖拽行为
闲聊: 小颖公司的项目之前要实现一个将左侧树中当前拖拽的内容,动态添加到右侧树种,虽然这个模块当时没有分给小颖,是同事完成的(小颖也不会嘻嘻),后来看了下他写代码,小颖自己写了个小demo.就当做个笔 ...
- 跟bWAPP学WEB安全(PHP代码)--SSL(Server-Side-Include)漏洞
什么是Server-Side-Include漏洞 服务端包含漏洞是指发送指令到服务器,服务器会将指令运行完,把运行结果包含在返回文件中发送给你.利用这种漏洞可以获取服务端的信息甚至执行命令,这样的指令 ...
- File类使用
简介 File类的实例代表了一个文件或者一个目录,通过API可以获取这个对象的相关信息. File类代表的文件或者目录可以真实存在,也可以是不存在的,可以使用File.exists()来判断. 在Wi ...
- iOS 禁止手势滑动翻页
- (void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; // 禁用 iOS7 返回手势 if ([self.navi ...
- Canvas裁剪Clip和Region、RegionIterator
extends:http://blog.csdn.net/lonelyroamer/article/details/8349601 裁剪功能由Canvas提供的一系列的clip...方法 和quick ...
- 慕课学习--OSI与TCP/IP网络协议
**OSI:开放系统互连参考模型 (Open System Interconnect 简称OSI)是国际标准化组织(ISO)和国际电报电话咨询委员会(CCITT)联合制定的开放系统互连参考模型,为开放 ...
- #if 和 #ifdef 条件编译注意
之前写程序很少用到这两个条件编译,只是在头文件的开头使用过 #ifdef ....<CODE>.... #endif,他是防止头文件被重复包含,导致的变量被多处声明或定义. 最近写程序发 ...
- iOS判断UIView是否显示在屏幕上
@interface - (BOOL)isDisplayedInScreen; @end @implementation UIView(UIScreenDisplaying) //判断View是否显示 ...