暴搜..

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. beego——模板处理

    beego的模板处理引擎采用的是Go内置的html/template包进行处理,而且beego的模板处理逻辑是采用了缓存编译方式, 也就是所有的模板会在beego应用启动的时候全部编译然后缓存在map ...

  2. day3-set集合

    set是一个无序且不重复的元素集合 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3 ...

  3. day13 迭代器

    迭代器 'iterable' 可迭代的 内部含有__iter__方法的数据类型就是可迭代的 —— 可迭代协议 print(dir([])) print(dir({})) print(dir(5)) p ...

  4. delphi编程创建桌面快捷方式

    delphi编程创建桌面快捷方式   uses ActiveX,ComObj,StdCtrls,ShlObj,FileCtrl; procedure TForm1.N2Click(Sender: TO ...

  5. 简单的menu和点击(包括alertDialog定制)

    import android.app.Activity;import android.app.AlertDialog;import android.app.Dialog;import android. ...

  6. oracle ORA-01704: string literal too long

    导出数据时,在SQL拼接处,提示 oracle ORA-01704: string literal too long sql:  WITH already_in AS (SELECT distinct ...

  7. 437. Path Sum III(路径可以任意点开始,任意点结束)

    You are given a binary tree in which each node contains an integer value. Find the number of paths t ...

  8. pycharm 常用配置

    lz提示一下,pycharm中的设置是可以导入和导出的,file>export settings可以保存当前pycharm中的设置为jar文件,重装时可以直接import settings> ...

  9. CSS3鼠标悬停8种动画特效

    在线演示 本地下载

  10. Maven的SSM框架配置文件:

    applicationContext.xml: <?xml version="1.0" encoding="UTF-8"?> <beans x ...