暴搜..

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. 编程语言的介绍(Day2)

    1.什么是编程,为什么要编程? 编程==编写程序(写代码) 2.编程语言有哪些 机器语言 优点是最底层,速度最快,缺点是最复杂,开发效率最低 汇编语言 优点是比较底层,速度最快,缺点是复杂,开发效率最 ...

  2. 解释一下python中的成员运算符

    通过成员运算符‘in’ 和 ‘not in’,我们可以确认一个值是否是另一个值的成员 print('me' in 'disappointment')#True print('us' in 'disap ...

  3. iOS程序的启动过程介绍

    大家在学习iPhone开发时候,都会写HelloWorld程序.大家一般都是通过向导,生成项目,然后通过模拟器启动应用程序.但是大家知道其背后的启动过程吗?也就是当点击程序图标启动程序开始到退出程序整 ...

  4. Python框架之Tornado (源码之褪去模板外衣)

    上一篇介绍了客户端请求在tornado框架中的生命周期,其本质就是利用epoll和socket来获取并处理请求.在上一篇的内容中,我们只是给客户端返回了简单的字符串,如:“Hello World”,而 ...

  5. 存在单点故障的namenode宕机恢复测试

    前提:如果namenode没有做HA,那么至少应该启用secondarynamenode,以便namenode宕机之后手动恢复数据 实验环境:3个节点(cenos 6.10) 测试前数据: 1.为了确 ...

  6. 请求库之requests,selenium

    requests模块 一.介绍 #介绍:使用requests可以模拟浏览器的请求,比起之前用到的urllib,requests模块的api更加便捷(本质就是封装了urllib3) #注意:reques ...

  7. Python面试题之Python的Super方法

    我们最常见的,可以说几乎唯一能见到的使用super的形式是: class SubClass(BaseClass): def method(self): super(SubClass, self).me ...

  8. CSS气泡提示框 可自定义配置箭头

    在线演示 本地下载

  9. 20162305 实验二 Java面向对象程序设计 实验报告

    20162305 实验二 Java面向对象程序设计 实验报告 实验内容 1.初步掌握单元测试和TDD 2.理解并掌握面向对象三要素:封装.继承.多态 3.初步掌握UML建模 4.熟悉S.O.L.I.D ...

  10. JavaWeb XML

    1. XML详解 1.1. XML介绍 1.1.1. 什么是XML XML的全称为eXtensible Markup Language,译为可扩展标记语言.XML语法上和HTML比较相似,但HTML中 ...