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. Sencha Cmd 5.0.1.231 是坑爹货

    Sencha Cmd 5.0.1.231相比之前的版本有了很大的变动,存在很多坑爹之处,个人建议不要升级到这个版本,如果已经升级了的就卸载了还原到以前的版本吧. 历史版本下载地址:http://cdn ...

  2. 配置Groovy开发环境(Windows)

    1.配置java环境 跳过具体配置 C:\Users\Administrator>java -version java version "1.8.0_45" Java(TM) ...

  3. H3C系列之三层交换机开启telnet管理的配置

    环境介绍>>>>>>>>>>>>>>>>>>>>交换机名牌:H3C交换机类型:三 ...

  4. elk单台环境搭建

    一.简介1.核心组成ELK由Elasticsearch.Logstash和Kibana三部分组件组成:Elasticsearch是个开源分布式搜索引擎,它的特点有:分布式,零配置,自动发现,索引自动分 ...

  5. wpgcms---碎片管理的使用

    这里很神奇的是碎片管理是编辑器,所以拿到的配置都是富文本,所以在前台作为字段来使用的时候,需要过滤掉字符串. 具体示例: {% set qq = wpg.fragment.get("qq&q ...

  6. 8.11 数据库ORM(5)

    2018-8-11 20:43:52 昨天从俺弟家回来了. 和俺弟聊天发现,他一直停留在自己目前的圈子,自己觉得很牛逼,比别人高人一等,, 读书无用论,,可以用 幸存者偏激理论 大概就是这个 可以否决 ...

  7. JavaWeb 后端 <三> 之 Response Request

    1. 响应对象 Response(重点:HTTP协议响应部分) 查看

  8. 初学Listener

    一. Listener 介绍 Servlet API提供了大量监听器来监听web应用的的内部事件,从而允许当web内部事件发生时回调事件监听器内的方法. 使用listener分为两步 定义LIsten ...

  9. uid列表来讲讲我是如何利用php数组进行排重的

    经常接到要对网站的会员进行站内信.手机短信.email进行群发信息的通知,用户列表一般由别的同事提供,当中难免会有重复,为了避免重复发送,所以我在进行发送信息前要对他们提供的用户列表进行排重. 假如得 ...

  10. PHP-FPM子进程过少解决办法

    /usr/local/php/var/log/php-fpm.log报一下错误 server reached pm.max_children setting (5), consider raising ...