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. PAT 1135 Is It A Red-Black Tree[难]

    1135 Is It A Red-Black Tree (30 分) There is a kind of balanced binary search tree named red-black tr ...

  2. 5.3 Components — Passing Properties to A Component

    1. 默认情况下,一个组件在它使用的模板范围中没有访问属性. 例如,假想你有一个blog-post组件被用来展示一个blog post: app/templates/components/blog-p ...

  3. php之isset empty is_null的区别

    isset:当前变量没有设置(即不存在),或者变量设置为null的时候,返回true,设置为“”或者0 都是返回的true empty:变量不存在,设置值为null,设置为“”,设置为0 都返回tru ...

  4. Python3.6(windows系统)通过pip安装bs4

    Python3.6(windows系统)通过pip安装bs4 cmd安装命令: pip install beautifulsoup4 执行结果:

  5. js 逗号操作符

    有一道js面试题,题目是这样的:下列代码的执行结果是什么,为什么? var i, j, k; for (i=0, j=0; i<10, j<6; i++, j++) { k = i+j; ...

  6. 20145319 《网络渗透》MSF基础应用

    20145319 <网络渗透>MSF基础应用 一 实验链接 渗透实验一:MS08_067渗透实验 渗透实验二:MS11_050渗透实验 渗透实验三:Adobe阅读器渗透实验 渗透实验四:M ...

  7. Android Studio安装与使用

    2013年谷歌推出android studio后,单独支持android开发,这是基于Java语言集成开发环境IntelliJ搭建的IDE.特别在android studio1.0稳定版出来后,谷歌将 ...

  8. personal evolution

    自我清醒 认知自我的行为和心理 你确定你自己是出于理智而发出某种行为? 首先需要确定哪些是人的天性 认知失调理论 从众效应 晕轮效应 霍桑效应 马太效应 期望效应 刻板效应 破窗效应 安排思维 安排闲 ...

  9. Git-远程仓库【转】

    本文转载自:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 远程仓库 到目前为止, ...

  10. fiddler几种功能强大的用法(二)

    参考网址:http://blog.rekfan.com/articles/228.html http://www.cnblogs.com/tugenhua0707/p/4637771.html htt ...