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. Promise 必知必会的面试题

    Promise 想必大家都十分熟悉,想想就那么几个 api,可是你真的了解 Promise 吗?本文根据 Promise 的一些知识点总结了十道题,看看你能做对几道. 以下 promise 均指代 P ...

  2. Eclipse 创建和读取yaml文件

    工具和用法: 1. eclipse插件包:org.dadacoalition.yedit_1.0.20.201509041456-RELEASE.jar 用法:将此jar包复制到eclipse-jee ...

  3. css修改select默认样式

    先来看看效果图: css: <style media="screen"> .select_demo, .select_list { width: 400px; heig ...

  4. 应用程序创建自己的奔溃转储(crash dump)文件

    1.注册自定义的UnhandledExceptionFilter,C/C++ Runtime Library下需要注意自定义handler被移除(hook kernel32.dll的SetUnhand ...

  5. Altium Designer 输出 gerber 光绘文件的详细说明

    Altium Designer 输出 gerber 光绘文件的详细说明 PCB画好后,我们需要输出光绘文件交给制版厂家.由此,输出光绘文件的重要性就显出来了. 先复习一下介绍各层的定义吧,哈哈 (1) ...

  6. 语音AT命令参考

    不知道 这AT指令是不是通用的,尝试过的给我个回复 语音命令 命令 描述 +FCLASS=8 进入语音模式.AT+FCLASS=8 将调制解调器置入语音模式.扩音电话和TAM模式包括在通用语音模式中, ...

  7. java 程序运行的基础知识【Java bytecode】

    聊聊文字,写一篇关于 java 基础知识的博文. JVM 线程栈 到 函数运行 每一个JVM线程来说启动的时候都会创建一个私有的线程栈.一个jvm线程栈用来存储栈帧,jvm线程栈和C语言中的栈很类似, ...

  8. selenium下firefox自动下载配置及问题

    在做自动化测试时,需要从网页上下载相关的文件到指定的目录,一直未能实现 网上正好有个blog文章介绍了如何下载 直接上代码: from selenium import webdriver import ...

  9. 第一个maven项目

    1.新建maven project 注意:勾上create a new simple project 2.填写相关信息, Grounp id为大项目名字,Artifact id为小项目的名字.注意:P ...

  10. js 的基础知识

    一.弱类型意识 js变量是没有类型的 var  a = 1;  //a 就是一个变量 不要提什么类型 变量可以赋任何类型的值 类型仅仅是值的性质 与变量无关 Js的基本类型 变量未赋值时,其值为und ...