暴搜..

class Solution(object):
def intervalIntersection(self, A: List[Interval], B: List[Interval]) -> List[Interval]:
"""
:type A: List[Interval]
:type B: List[Interval]
:rtype: List[Interval]
"""
ans = []
for interval_b in B:
for interval_a in A:
t = self.intersection(interval_a, interval_b)
if t:
ans.append(t)
return ans def intersection(self, a: Interval, b: Interval):
if a.end < b.start or b.end < a.start:
return None
return Interval(max(a.start, b.start), min(a.end, b.end))

Leetcode 986. Interval List Intersections的更多相关文章

  1. Java实现LeetCode #986 - Interval List Intersections

    class Solution { public: vector<Interval> intervalIntersection(vector<Interval>& A, ...

  2. 【LeetCode】986. Interval List Intersections 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 双指针 日期 题目地址:https://leetco ...

  3. 【leetcode】986. Interval List Intersections

    题目如下: Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted ...

  4. 【leetcode】986. Interval List Intersections (双指针)

    You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, ...

  5. LC 986. Interval List Intersections

    Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order ...

  6. leetcode Insert Interval 区间插入

    作者:jostree  转载请注明出处 http://www.cnblogs.com/jostree/p/4051169.html 题目链接:leetcode Insert Interval 使用模拟 ...

  7. [LeetCode] Insert Interval 插入区间

    Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessa ...

  8. [Swift]LeetCode986. 区间列表的交集 | Interval List Intersections

    Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order ...

  9. [leetcode]Insert Interval @ Python

    原题地址:https://oj.leetcode.com/problems/insert-interval/ 题意: Given a set of non-overlapping intervals, ...

随机推荐

  1. Matplot相关(二)——统计图

    Matplotlib:其能够支持所有的2D作图和部分3D作图.能通过交互环境做出印刷质量的图像. ————————缩写定义———————— import matplot.pyplot as plt — ...

  2. ununtu16.04+python3+selenium+firefox环境搭建

    一.初始配置: 1.安装完系统并配置好地址及DNS.2.设置root密码: sudo passwd root 3.更改云源: sudo cp /etc/apt/sources.list /etc/ap ...

  3. Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) E. Tree Folding

    地址:http://codeforces.com/contest/765/problem/E 题目: E. Tree Folding time limit per test 2 seconds mem ...

  4. HDU - 1151 Air Raid (最小路径覆盖)

    题意:给定一个有向无环图,求最少划分几条路径,使之能够覆盖所有点. 分析:这可以转化为DAG上的最小路径覆盖问题. 路径覆盖的定义:有向图中,路径覆盖就是在图中找一些路径,使之覆盖了图中的所有顶点,且 ...

  5. Spring4.2.3+Hibernate4.3.11整合( IntelliJ maven项目)(使用Annotation注解)(Junit测试类)

    1. 在IntelliJ中新建maven项目 给出一个建好的示例 2. 在pom.xml中配置依赖 包括: spring-context spring-orm hibernate-core mysql ...

  6. url末尾的斜杠作用探秘

    今天突然好奇,想区分www.abc.com/efg 和www.abc.com/efg/这两个网址的区别.即分析一下url末尾加个斜杠是否有特殊的效果. 找到网上的介绍: 当Web服务器接收到对某个末尾 ...

  7. js自执行函数&扩展方法

    我们通常将JS代码写在一个单独的JS文件中,然后在页面中引入该文件.但是,有时候引入后会碰到变量名或函数名与其它JS代码冲突的问题.那么如何解决这个问题呢?作用域隔离.在JS中,作用域是通过函数来划分 ...

  8. html 5中的新特性之强化表单元素及属性

    之前我们判断用户提交的是否是Email 的时候,往往使用js 进行判断,但在html5中可以有新的方式进行判断而且更简单 <!DOCTYPE html> <html lang=&qu ...

  9. Docker_remote_api未授权访问漏洞

    docker remote  api主要的目的是取代命令行界面, docker client和docker daemon通过unix domain socket进行通信. 默认情况下,只有本机的roo ...

  10. Logback Pattern 日志格式配置

    Logback日志配置示例 <appender name="SYSLOG" class="ch.qos.logback.classic.net.SyslogAppe ...