【题目描述】

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. Jetty入门(1-3)Eclipse集成gradle-Gretty插件或maven-jetty插件运行应用

    英文来源:  http://akhikhl.github.io/gretty-doc/Getting-started.html 一.gradle插件 1.使用gretty来运行jetty: gradl ...

  2. python xml.dom模块解析xml

    1. 什么是xml?有何特征? xml即可扩展标记语言,它可以用来标记数据.定义数据类型,是一种允许用户对自己的标记语言进行定义的源语言. 例子:del.xml <?xml version=&q ...

  3. python Mysql (二)

    Mysql (二) 一. 事务 a.数据库开启事务命令 1 2 3 4 #start transaction 开启事务 #Rollback 回滚事务,即撤销指定的sql语句(只能回退insert de ...

  4. oracle12c:通过oracle客户端工具配置tns,并使用sqlldr进行批量导入数据

    通过oracle客户端工具配置tns: 进入oracle配置工具“Net Configuration Assistant”-> 点击“下一步”,完成tns配置. 测试是否tns可用 命令:tns ...

  5. PIL绘图

    # coding:utf-8 # PIL的ImageDraw 提供了一系列绘图方法,让我们可以直接绘图.比如要生成字母验证码图片 from PIL import Image, ImageDraw, I ...

  6. 编码注释coding: utf-8

    # -*- coding: utf-8 -*- PY文件当中是不支持中文的,即使你输入的注释是中文也不行,为了解决这个问题,就需要把文件编码类型改为UTF-8的类型,输入这个代码就可以让PY源文件里面 ...

  7. 一 Django模型层简介(一)

    模型 django提供了一个强大的orm(关系映射模型)系统. 模型包含了你要在数据库中创建的字段信息及对数据表的一些操作 使用模型 定义好模型后,要告诉django使用这些模型,你要做的就是在配置文 ...

  8. 031718-js变量、数据类型、运算符

    1.关键字.标识符.变量(是一个名称,最好用字母开头,对大小写敏感).常量 (是有数据类型的一个值) 变量: ①定义并赋值 ②使用   2.数据类型:数字  字符串  布尔  null  undefi ...

  9. MyBatis 与 Spring 整合

    MyBatis-Spring 项目 目前大部分的 Java 互联网项目,都是用 Spring MVC + Spring + MyBatis 搭建平台的. 使用 Spring IoC 可以有效的管理各类 ...

  10. 重拾Python(5):数据读取

    本文主要对Python如何读取数据进行总结梳理,涵盖从文本文件,尤其是excel文件(用于离线数据探索分析),以及结构化数据库(以Mysql为例)中读取数据等内容. 约定: import numpy ...