当前位置:网站首页>0 dynamic planning leetcode1024. Video splicing
0 dynamic planning leetcode1024. Video splicing
2022-07-23 12:53:00 【18 ARU】
analysis
Dynamic programming
dp[i] From 0 To i Seconds requires at least a few pieces of material .dp[i] = Math.min(dp[i],dp[ Left endpoint of a material ]+1);
dp[i] The value concept of is to traverse all the materials containing the current second , Select from 0 To i The material that needs the least material .
class Solution {
public int videoStitching(int[][] clips, int time) {
int[] dp = new int[time+1];
Arrays.fill(dp, time+1);
dp[0] = 0;
for (int i = 1; i <= time; i++) {
for (int j = 0; j < clips.length; j++) {
if (clips[j][0] <= i && clips[j][1] >= i) {
dp[i] = Math.min(dp[i],dp[clips[j][0]]+1);
}
}
}
if (dp[time] > time) {
return -1;
}
return dp[time];
}
}
边栏推荐
- Learning diary - (routing and switching technology) OSPF Protocol
- HCIP---MGRE综合实验
- Hcip - first experiment
- Unity3d:特效对象池,超时删除池内GameObject,GC权值
- C #: quick sort. If there is the same number, it will be ignored, and then continue the previous search direction to find the next number that meets the requirements for replacement
- 剖析Redis服务器
- C custom queue set
- Learning diary (routing and switching technology) -- floating static routing and default routing
- Understanding of LSM tree (log structured merge tree)
- DNS域名解析服务
猜你喜欢
随机推荐
C # custom bidirectional linked list
第一类错误离我们有多远
学习日记——(路由与交换技术)动态路由(rip协议)和静态路由
Learning diary - (routing and switching technology) single arm routing
DHCP原理与配置
Hcip--- BGP related configuration
Hcip --- OSPF details
Hcip --- HCIA knowledge review (I)
Do a Cisco experiment!
FTP实验及概述
Unity3d: ugui source code, rebuild optimization
详解TCP连接的释放
Explain the release of TCP connection in detail
浅析互联网协议(二)
Explain the interactive data flow and block data flow of TCP in detail
Analysis of Internet Protocol (I)
HCIP---MGRE综合实验
Analyze redis cluster
C: stack stack source code, array stack, chain stack
学习日记——(路由与交换技术)单臂路由









