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. Python学习开发资源大全列表

    1 机器学习和计算机视觉 Crab:灵活.快速的推荐引擎 gensim:人性化的话题建模库 hebel:GPU 加速的深度学习库 NuPIC:智能计算 Numenta 平台 pattern:Pytho ...

  2. 用Python实现的数据结构与算法:堆栈

    一.概述 堆栈(Stack)是一种后进先出(LIFO)的线性数据结构,对堆栈的插入和删除操作都只能在栈顶(top)进行. 二.ADT 堆栈ADT(抽象数据类型)一般提供以下接口: Stack() 创建 ...

  3. 使用Markdown写博客

    初识Markdown Markdown是一种轻量级的「标记语言」,它的优点很多,目前也被越来越多的写作爱好者,撰稿这广泛使用.Markdown的设计目标是「易读易写」,语法十分简单,常用的标记符号不超 ...

  4. 11月16host文件

    #################################################################################################### ...

  5. 裸眼3D全攻略3:拍摄3D—瞳距、镜距、视角偏转与空间感

    http://sd89.blog.163.com/blog/static/356041322014112532958728/ 3D图片的拍摄,与平面有着全新的不同要求,那就是空间感的表现. 简单来说, ...

  6. Centos75 安装 postgresql11

    切换到root账户, #安装yum 源 yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_6 ...

  7. 框架-spring入门总结

    框架-spring入门总结 参考: http://www.cnblogs.com/heavenyes/p/3908546.html http://www.cnblogs.com/heavenyes/p ...

  8. 【bzoj4972】小Q的方格纸 前缀和

    题目让O(1)预处理出来 类三角形边界及内部的和 根据这个图 就是一个大矩形-左边的绿色的矩形 - 蓝色的大三角形 + 右上角突出的蓝色的小三角形 #include<bits/stdc++.h& ...

  9. Android 引用资源

    比如在 strings.xml 中找到的 Hello world!字符串,我们有两种方式可以引用它: 1. 在代码中通过 R.string.hello_world 可以获得该字符串的引用: 2. 在 ...

  10. [OSG]OSG的相关扩展

    参考:osg官网 http://www.osgchina.org/index.php?view=article&id=176 http://trac.openscenegraph.org/pr ...