[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 ...
随机推荐
- java基础---->数组的基础使用(二)
这里对List(jdk 1.7)列表里面的一些方法做一些简单的分析,以避免有些函数的误用.手写瑶笺被雨淋,模糊点画费探寻,纵然灭却书中字,难灭情人一片心. List中注意的方法 一.Arrays.as ...
- 自己实现atoi
bool myatoi(const char *s,int &num) { cout<<(&s)<<endl; num=; while (*s) { ') { ...
- sencha touch 坑爹的Panel,数据不显示了...
一位同学问我一个问题: sencha touch中xtype创建dataview死活不显示!!版本2.3.1,MVC模式,sencha touch创建目录程序很简单,主界面一个tabPanel,两个分 ...
- rabbitmq在centos 7上的安装
一.安装步骤 参考了官网文档: http://www.rabbitmq.com/install-rpm.html#package-dependencies 这里大概介绍下. rabbitmq-serv ...
- psr-4
自动加载: <?php function autoload($className) { $className = ltrim($className, '\\'); $fileName = ''; ...
- php 函数合并 array_merge 与 + 的区别
array_merge()是PHP语言中的一个函数,作用是将两个或多个数组的单元合并起来,一个数组中的值附加在前一个数组的后面.返回作为结果的数组. 如果输入的数组中有相同的字符串键名,该键的键值为最 ...
- 2015.7.7js-07-2(基础)
1.用求模来计算时间,秒%60,就能获取剩余的秒 var s = 362; var minute = parseInt(s/60) + "分" //取得分 var second = ...
- 将Linux系统的字体全改成中文
# 修改字符集,否则可能报 input/output error的问题,因为日志里打印了中文 $ localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8 $ export ...
- docker link 过时不再用了?那容器互联、服务发现怎么办?
在 1-2 年前,Docker 所有容器都连接于默认的桥接网络上,也就是很多老文章鼓捣的 docker0 桥接网卡.因此实际上默认情况下所有容器都是可以互联的,没有隔离,当然这样安全性不好.而服务发现 ...
- ALTERA FPGA Quartus 指定memory综合使用 M4K块
最近遇到个问题, 使用二位数组方式定义了一个RAM ,但是软件每次 都是使用逻辑单元综合 这块memory , 在ALTERA的网页上 找到了 方法,,在定义的 memory前面加一句画 (* ra ...