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. ArcEngine和GDAL读写栅格数据机制对比(一)

    最近应用AE开发插值和栅格转等值线的程序,涉及到栅格读写的有关内容.联想到ArcGIS利用了GDAL的某些东西,从AE的OMD中也发现RasterDataset和RasterBand这些命名和GDAL ...

  2. <option> 标签的 value 属性

    <html> <body> <form action="/example/html/form_action.asp" method="get ...

  3. Java游戏服务器成长之路——你好,Mongo

    关于mongo的思考 第一阶段的弱联网游戏已基本完成,截至今天下午,测试也基本差不多了,前端还有一些小bug需要优化,接下来会接入小米,360,百度,腾讯等平台,然后推广一波,年前公司还能赚一笔,而我 ...

  4. 3.4 Templates -- Displaying A List of Items(展示一个集合)

    一. 概述 1. example 如果你需要遍历一个对象集合,使用Handlebars的{{#each}}. <ul> {{#each people key="id" ...

  5. Ubuntu 添加用户到 sudoer

    一.概述 新建用户后,我们可能需要该用户能够使用一些越权的东西.sudo命令能够暂时提升该用户的权限到root,但是前提是要求该用户存在与 sudoer list 中. sudoers 存储在 /et ...

  6. VS2010/MFC编程入门之二十二(常用控件:按钮控件Button、Radio Button和Check Box)

    言归正传,鸡啄米上一节中讲了编辑框的用法,本节继续讲解常用控件--按钮控件的使用. 按钮控件简介 按钮控件包括命令按钮(Button).单选按钮(Radio Button)和复选框(Check Box ...

  7. Python 自带IDLE 如何打开

  8. Android 自定义View - 饼图

    最近有看到一个自定义等分圆的View,自己尝试做了一个类似的,效果图如下图(1)所示: 图(1) 实现方法:自定义View-ColorCircle,需要的知道的值有圆的半径,等分个数以及扇形颜色. / ...

  9. SQL优化之limit 1

    在某些情况下,如果明知道查询结果只有一个,SQL语句中使用LIMIT 1会提高查询效率.  例如下面的用户表(主键id,邮箱,密码): create table t_user( id int prim ...

  10. 安装tensorflow报ImportError: libcublas.so.9.0: cannot open shared object file的解决方法【转】

    本文转载自:https://blog.csdn.net/qq_37274615/article/details/81099738 转载自:https://blog.csdn.net/qysh123/a ...