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的更多相关文章

  1. [LeetCode] 252. Meeting Rooms 会议室

    Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...

  2. LeetCode 252. Meeting Rooms (会议室)$

    Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...

  3. [LeetCode#252] Meeting Rooms

    Problem: Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2] ...

  4. [leetcode]252. Meeting Rooms会议室有冲突吗

    Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...

  5. [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 ...

  6. [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 ...

  7. [LeetCode] 253. Meeting Rooms II 会议室 II

    Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...

  8. [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 ...

  9. [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 ...

随机推荐

  1. 【数据库系列】MySql中的select的锁表范围

    由于InnoDB预设的是Row-Level Lock,只有明确指定主键的时候MySql才会执行Row lock,否则MySql将会执行Table Lock. 1.明确指定主键则是行锁 2.明确指定主键 ...

  2. C# 泛型的简单讲解和应用

    泛型 什么是泛型 泛型是 2.0 版 C# 语言和公共语言运行库 (CLR) 中的一个新功能.泛型将类型参数的概念引入 .NET Framework,类型参数使得设计如下类和方法成为可能:这些类和方法 ...

  3. Android 4.0的图形硬件加速及绘制技巧

    转:http://zuiniuwang.blog.51cto.com/3709988/721798 从Android 3.0开始,Android 2D的绘制流程就设计为能够更好地支持硬件加速.使用GP ...

  4. Android 缓存策略demo

    packageinstaller\permission\model\PermissionApps.java /** * Class used to reduce the number of calls ...

  5. win10下网狐荣耀手机端android app编译

    基于荣耀版(2017.5.21)12 款游戏..7z这款游戏,网上有下载的 1.解压后进入 cd shoujiduan 2.将client/base复制到client/ciphercode/下,也就是 ...

  6. ELK系列二:Elasticsearch的架构原理和配置优化

    1.Elasticsearch的数据组织架构 1.1.Elasticsearch结构概念 集群(cluster):拥有相同cluster-name的elasticsearch结点的集合(每个结点其实就 ...

  7. /usr/bin/ld: i386:x86-64 architecture of input file `command.o' is incompatible with i386 output

    /usr/bin/ld: i386:x86-64 architecture of input file `command.o' is incompatible with i386 output 出现这 ...

  8. thinkphp5部署在宝塔面板问题!

    遇到一个问题,就是当thinkphp5部署在宝塔面板上,会出现这个问题: 参考解决办法: http://www.thinkphp.cn/topic/56589.html 首先:thinkphp5的目录 ...

  9. 无向连通图求割边(桥)hdu4738,hdu3849

    点击打开链接 题目链接:   hdu 4738 题目大意:   曹操有N个岛,这些岛用M座桥连接起来 每座桥有士兵把守(也可能没有) 周瑜想让这N个岛不连通,但只能炸掉一座桥 并且炸掉一座桥需要派出不 ...

  10. 9.20Ajax知识sweetalet

    2018-9-20 14:19:55 2018-9-20 21:33:05 周末可以帮我图书商城再次优化一下!! 加入 Ajax请求,,再加上 sweetAlert  甜蜜对话框插件! 要是再加上模态 ...