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, ...
随机推荐
- 基本数据类型(Day4)
一 什么是数据? eg:x=10 则10是要存储的数据 二 为什么数据要分不同的类型? 数据是用来表示不同状态的,当然不同的状态可以用不同的数据表示 三 数据类型 1.数字(整型,长整型 ,浮 ...
- Django日志
Django日志 简单的Django日志 在settings里配置,会在屏幕输出日志 LOGGING = { 'version': 1, 'disable_existing_loggers': Fal ...
- linux 基础知识总结2
1. 设定文件text的属性为:文件属主(u) 增加写权限;与文件属主同组用户(g) 增加写权限;其他用户(o) 删除执行权限:chmod ug+w,o-x log2012.log 权限选择参 ...
- 【笔记】css3实现网页平滑过渡效果...
参考:http://www.imooc.com/video/7142 未完. <!DOCTYPE html> <html> <head> <meta char ...
- 使用IDEA整合SSM框架
一.安装环境和开发工具 在整合Spring,SpringMVC 和 MyBatis 的过程中,很容易遇到一些小问题,因此记录下整合过程. 首先是安装环境和开发工具,如下: Window 7 Jdk 1 ...
- Facebook力推导航库:React Navigation使用详解
本文来自Songlcy投稿:文章地址:http://blog.csdn.net/u013718120/article/details/72357698 一.开源库介绍 今年1月份,新开源的react- ...
- Address already in use: make_sock: could not bind to address [::]:80
**********************************************************处理办法:# ps -aux | grep httpWarning: bad syn ...
- 【bzoj4806~bzoj4808】炮车马后——象棋四连击
bzoj4806——炮 题目传送门:bzoj4806 这种题一看就是dp...我们可以设$ f[i][j][k] $表示处理到第$ i $行,有$ j $列没放炮,$ k $列只放了一个炮.接着分情况 ...
- CSS + Jquery
关于 position 1.父视图通过设置relative 子视图设置absolute ,这样可以相当于父视图来设置. 2.relative 不脱离文本流 位置还保留着 3.absolute 脱离 ...
- Moore majority vote algorithm(摩尔投票算法)
Boyer-Moore majority vote algorithm(摩尔投票算法) 简介 Boyer-Moore majority vote algorithm(摩尔投票算法)是一种在线性时间O( ...