[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 ...
随机推荐
- 游戏服务器学习笔记 4———— master 模块介绍
(模块的介绍方法都是先说大体功能,在捡一些细节详细讨论.) master 类很简单,就3个函数,一个init,设置配置信息,并调用masterapp,然后还有一个循环启动子进程的start函数. 这里 ...
- linux 文件编码问题
iconv -f UTF- -t gb18030 file_input -o file_output 上述命令不一定有用. 大概了解下文件编码,和vim里面的编码情况. 1 字符编码基础知识 字符编码 ...
- Windows平台下PHP7添加Sqlserver扩展
1.7.0.x 7.0.x的扩展下载地址: Microsoft Drivers for PHP for SQL Server https://www.microsoft.com/en-us/down ...
- Build step 'Execute Windows batch command' marked build as failure
坑爹的Jenkis,在执行windows命令编译.NET项目的时候命令执行成功了,但是却还是报了这样一个错: Build step 'Execute Windows batch command' ma ...
- VC++组合框——学习笔记1(组合框选项的添加和无法显示下拉选项)
VC++控件 ---组合框 环境VC2003 1.组合框添加下拉菜单选项 现在有尝试了两个命令 (m_com为组合框控control类型的变量.) 方法一 m_com.AddString(&qu ...
- mysql5.5版本和mysql 5.6版本具体有哪些区别?
mysql5.6较5.5其中有一个很大的好处,比如给表加字段的时候,5.5或以前的版本会锁表,5.6就不会锁表,而且速度很快. MySQL 5.6 对默认配置进行了一些微调,这些调整大多数都非常不错, ...
- [EF]vs15+ef6+mysql code first方式
写在前面 前面有篇文章,尝试了db first方式,但不知道是什么原因一直没有成功,到最后也没解决,今天就尝试下code first的方式. [EF]vs15+ef6+mysql这个问题,你遇到过么? ...
- PAT-GPLT L1-039 - 古风排版 - [字符串输入输出]
题目链接:https://www.patest.cn/contests/gplt/L1-039 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standar ...
- [Oracle]Oracle之Chr函数返回
Chr函数 返回:返回 String,其中包含有与指定的字符代码相关的字符. chr('39')是单引号 Chr("0") 为0的字符 Chr("1") Chr ...
- Oracle安全之 Oracle 11g flashback技术详解
Oracle11g提供的闪回技术用于对抗人为错误,主要有以下7种技术组成: 闪回查询-(闪回时间查询.闪回版本查询): 闪回数据归档: 闪回事务查询: 闪回事务: 闪回表: 闪回删表: 闪回数据库. ...