【题目描述】

Given an interval list which are flying and landing time of the flight. How many airplanes are on the sky at most?

Notice:If landing and flying happens at the same time, we consider landing should happen at first.

给出飞机的起飞和降落时间的列表,用 interval 序列表示. 请计算出天上同时最多有多少架飞机?

【注】如果多架飞机降落和起飞在同一时刻,我们认为降落有优先权。

【题目链接】

www.lintcode.com/en/problem/number-of-airplanes-in-the-sky/

【题目解析】

1) 将start和end时间分别保存在两个list中,并对两个list排序。

2) 从两个list的第一个元素开始比较,若start小于end,则天上增加一架飞机,并将start进一位,反之则天上减少一架飞机,并将end进一位。记录每次增加飞机后天上飞机数量的最大值。

3) 当start遍历完成时,返回此时最大值。

【参考答案】

www.jiuzhang.com/solutions/number-of-airplanes-in-the-sky/

著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

Lintcode391 Number of Airplanes in the Sky solution 题解的更多相关文章

  1. Number of Airplanes in the Sky

    Given an interval list which are flying and landing time of the flight. How many airplanes are on th ...

  2. LintCode: Number of Airplanes in the Sky

    C++ (1)把interval数组中的所有start和所有end放在同一个数组中,然后进行排序,遇到start就起飞一架飞机,遇到一架end就降落一架飞机,所以start有个+1属性,end有个-1 ...

  3. Lintcode249 Count of Smaller Number before itself solution 题解

    [题目描述] Give you an integer array (index from 0 to n-1, where n is the size of this array, data value ...

  4. Lintcode248 Count of Smaller Number solution 题解

    [题目描述] Give you an integer array (index from 0 to n-1, where n is the size of this array, value from ...

  5. Lintcode401 Kth Smallest Number in Sorted Matrix solution 题解

    [题目描述] Find the kth smallest number in at row and column sorted matrix. 在一个排序矩阵中找从小到大的第 k 个整数. 排序矩阵的 ...

  6. Lintcode360 Sliding Window Median solution 题解

    [题目描述] Given an array of n integer, and a moving window(size k), move the window at each iteration f ...

  7. Lintcode247 Segment Tree Query II solution 题解

    [题目描述] For an array, we can build a Segment Tree for it, each node stores an extra attribute count t ...

  8. Lintcode373 Partition Array by Odd and Even solution 题解

    [题目描述] Partition an integers array into odd number first and even number second. 分割一个整数数组,使得奇数在前偶数在后 ...

  9. CF742B Arpa's obvious problem and Mehrdad's terrible solution 题解

    Content 有一个长度为 \(n\) 的数组,请求出使得 \(a_i \oplus a_j=x\) 且 \(i\neq j\) 的数对 \((i,j)\) 的个数.其中 \(\oplus\) 表示 ...

随机推荐

  1. JWT(JSON Web Token) 多网站的单点登录,放弃session

    多个网站之间的登录信息共享, 一种解决方案是基于cookie - session的登录认证方式,这种方式跨域比较复杂. 另一种替代方案是采用基于算法的认证方式, JWT(json web token) ...

  2. vscode调试适配器已意外终止

    出现这个错误了,找半天没找到办法.师兄支了一招: 把图中红圈部分删掉! 这是个旧的配置文件 ,你删掉它(反正一直报错误,也用不成了!).然后你调试一个文件,它会重新自动添加新的配置文件.

  3. Python学习之中文注释问题

    简单写个输入.输出,并注释 # 输入 print'100+200=',100+200 # 输入 name = raw_input() 报错了: SyntaxError: Non-ASCII chara ...

  4. 浅谈 Mybatis中的 ${ } 和 #{ }的区别

    好了,真正做开发也差不多一年了.一直都是看别人的博客,自己懒得写,而且也不会写博客,今天就开始慢慢的练习一下写博客吧.前段时间刚好在公司遇到这样的问题. 一.举例说明 select * from us ...

  5. django Form组件 上传文件

    上传文件 注意:FORM表单提交文件要有一个参数enctype="multipart/form-data" 普通上传: urls: url(r'^f1/',views.f1), u ...

  6. Docker:云栖社区开源论题及Spark开源论题

    https://yq.aliyun.com/topic/78?spm=5176.8290451.656547.7.rMYhAF https://yq.aliyun.com/activity/155?u ...

  7. 使用 WTForms 进行表单验证的例子

    #使用 WTForms 进行表单验证的例子 from wtforms import Form from wtforms import BooleanField from wtforms import ...

  8. MySQL 5.7 基于复制线程SQL_Thread加快恢复的尝试

    1. MySQL 数据恢复常用办法 MySQL恢复的方法一般有三种: 1. 官方推荐的基于全备+binlog , 通常做法是先恢复最近一次的全备,然后通过mysqlbiinlog --start-po ...

  9. CentOS 7 源码编译安装MySQL 5.7.14

    一.添加用户和组 1. 进入root: su 2. 添加组: groupadd mysql 3. 添加用户: useradd -r -g mysql -s /bin/false mysql 二.安装 ...

  10. Redis、Memcache与MongoDB的区别

    >>Memcached Memcached的优点:Memcached可以利用多核优势,单实例吞吐量极高,可以达到几十万QPS(取决于key.value的字节大小以及服务器硬件性能,日常环境 ...