class Solution:
def helper(self,l,r,clips)->int:
maxL,maxR=0,0
iL,iR=-1,-1
for i,c in enumerate(clips):
if c[0]<=l and c[1]>=r:
return 1
if c[0]<=l:
if c[1]-l>maxL:
maxL=c[1]-l
iL=i
if c[1]>=r:
print(r,c[0],c[1],maxR)
if r-c[0]>maxR:
maxR=r-c[0]
iR=i
if iL==-1 or iR==-1:
return -1 new_l=clips[iL][1]
new_r=clips[iR][0]
if clips[iL][0]==clips[iR][0] and clips[iL][1]==clips[iR][1]:
return 1
if new_l>=new_r:
return 2
clips=[c for i,c in enumerate(clips) if i not in (iL,iR)]
return 2+self.helper(new_l,new_r,clips) def videoStitching(self, clips: List[List[int]], T: int) -> int:
return self.helper(0,T,clips)

Leetcode 1024. Video Stitching的更多相关文章

  1. 【LeetCode】1024. Video Stitching 解题报告(Python)

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

  2. 【leetcode】1024. Video Stitching

    题目如下: You are given a series of video clips from a sporting event that lasted Tseconds.  These video ...

  3. 1024. Video Stitching

    //使用java dfs public int videoStitching(int[][] clips, int T) { //bfs Queue<Integer> queue = ne ...

  4. [Swift]LeetCode1024. 视频拼接 | Video Stitching

    You are given a series of video clips from a sporting event that lasted T seconds.  These video clip ...

  5. Weekly Contest 131

    1021. Remove Outermost Parentheses A valid parentheses string is either empty (""), " ...

  6. Swift LeetCode 目录 | Catalog

    请点击页面左上角 -> Fork me on Github 或直接访问本项目Github地址:LeetCode Solution by Swift    说明:题目中含有$符号则为付费题目. 如 ...

  7. FFMPEG系列课程(一)打开视频解码器

    测试环境:windows10 开发工具:VS2013 从今天开始准备些FFmpeg的系列教程,今天是第一课我们研究下打开视频文件和视频解码器.演示环境在windows上,在Linux上代码也是一样. ...

  8. leetcode & lintcode for bug-free

    刷题备忘录,for bug-free leetcode 396. Rotate Function 题意: Given an array of integers A and let n to be it ...

  9. leetcode & lintcode 题解

    刷题备忘录,for bug-free 招行面试题--求无序数组最长连续序列的长度,这里连续指的是值连续--间隔为1,并不是数值的位置连续 问题: 给出一个未排序的整数数组,找出最长的连续元素序列的长度 ...

随机推荐

  1. [css]浮动-清除浮动的3种方法

    清除浮动的方法: 内墙法 注: 这是个奇淫技巧,没什么原理可言,记住即可 这个技巧又使得父box重新可以被子box撑开高度了. 隔墙法-适用于2个box之间上下排列 由于2个box高度依旧是0, 彼此 ...

  2. 【转】Deep Learning(深度学习)学习笔记整理系列之(一)

    Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0  2013-0 ...

  3. IBM WebSphere MQ for net 报错 MQRC_NOT_AUTHORIZED

    最近进入新公司要维护以前的90年代的老系统 用NET对IBMMQ做测试 NET 4.0 +7.5 MQ 版本 待我写好NET调用的代码后出现错误MQRC_NOT_AUTHORIZED 折腾大半天往上找 ...

  4. 服务器相关 HTTP 请求错误

    HTTP 400 - 请求无效 HTTP 401.1 - 未授权:登录失败 HTTP 401.2 - 未授权:服务器配置问题导致登录失败 HTTP 401.3 - ACL 禁止访问资源 HTTP 40 ...

  5. DB杂记

    1. mybatits 批量插入: <insert id="insertColumnitem2"> INSERT INTO REPORT_COLUMNITEM (COL ...

  6. aTool在线工具

    在线HTTP POST/GET接口测试工具 - aTool在线工具 地址:http://www.atool.org/httptest.php在线接口测试工具接口测试是测试系统组件间接口的一种测试.接口 ...

  7. 高可用Mysql架构_Haproxy+keepalived+mycat集群的配置

    接上一篇文章http://www.cnblogs.com/wt645631686/p/8310891.html,虽然已经在原有两台mycat基础上增加了Haproxy作为mycat的中间服务器,不足的 ...

  8. 20189215《Linux内核原理与分析》第一周作业

    实验1 Linux系统简介 本节主要学习了 Linux 的历史,Linux 与 Windows 的区别等入门知识.通过学习,我明确了目的,是要用 Linux 来做程序开发.搭建服务器等:并且非常接受不 ...

  9. 试着用React写项目-利用react-router解决跳转路由等问题(一)

    转载请注明出处:王亟亟的大牛之路 继续本周的大方向,继续学习React,昨天把简单的hi all内容呈现出来后,今天研究如何多页面或者实现页面嵌套, 开始今天的内容前老规矩,先安利:https://g ...

  10. 计算机基础教程11 - 互联网&内联网

    在本章中,我们将看到什么是Internet和Intranet,以及讨论两者之间的异同. 互联网 它是互联计算机网络的全球/全球系统.它使用标准的Internet协议(TCP / IP).Interne ...