Leetcode 986. Interval List Intersections
暴搜..
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的更多相关文章
- Java实现LeetCode #986 - Interval List Intersections
class Solution { public: vector<Interval> intervalIntersection(vector<Interval>& A, ...
- 【LeetCode】986. Interval List Intersections 解题报告(C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 双指针 日期 题目地址:https://leetco ...
- 【leetcode】986. Interval List Intersections
题目如下: Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted ...
- 【leetcode】986. Interval List Intersections (双指针)
You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, ...
- LC 986. Interval List Intersections
Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order ...
- leetcode Insert Interval 区间插入
作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4051169.html 题目链接:leetcode Insert Interval 使用模拟 ...
- [LeetCode] Insert Interval 插入区间
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessa ...
- [Swift]LeetCode986. 区间列表的交集 | Interval List Intersections
Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order ...
- [leetcode]Insert Interval @ Python
原题地址:https://oj.leetcode.com/problems/insert-interval/ 题意: Given a set of non-overlapping intervals, ...
随机推荐
- mysql第一天作业
1.在一个数据库中创建学生表,要求字段id,姓名,年纪三个字段:要求id为主键 2.在学生表添加一个班级字段,字符串类型,非空约束 3.将姓名字段改为唯一约束 4.将学生表名改为stu
- Linux Shell编程第3章——正则表达式
目录 正则表达式基础 正则表达式的扩展 通配 grep命令 正则表达式基础 Linux Shell以字符串作为表达式向系统传达意思.元字符(Metacharacters)是用来阐述字符表达式意义的字符 ...
- Python 实习遇见的各种面试题
Python 语法 说说你平时 Python 都用哪些库 == 和 is 区别. == 是比较两对象的值,is 是比较在内存中的地址(id), is 相当于 id(objx) == id(objy). ...
- js 科学计数法
function convertNum(num_str){ //参数必须为 字符串 //科学计数法字符 转换 为数字字符, 突破正数21位和负数7位的Number自动转换 // 兼容 小数点左边有多位 ...
- JS与Jquery 中的extend用法不同
1, Jquery //jQuery 应用扩展 jQuery.extend({ // 定义setApDiv setApDiv:function () { ...
- Cookie应用参考
内容来自imooc.
- 分布式集群Session原理及实现共享
1.什么是Session/Cookie? 用户使用网站的服务,基本上需要浏览器与Web服务器的多次交互.HTTP协议本身是无状态的,当用户的第一次访问请求结束后,后端服务器就无法知道下一次来访问的还是 ...
- BUG: scheduling while atomic 分析【转】
本文转载自:https://blog.csdn.net/cfy_phonex/article/details/12090943 遇到一个典型的schedule问题. <3>[26578 ...
- AtCoder Regular Contest 094
AtCoder Regular Contest 094 C - Same Integers 题意: 给定\(a,b,c\)三个数,可以进行两个操作:1.把一个数+2:2.把任意两个数+1.求最少需要几 ...
- eclipse设置控制台字体大小
步骤如下