美文网首页
1024. 视频拼接

1024. 视频拼接

作者: 漫行者_ | 来源:发表于2022-01-06 21:19 被阅读0次
    func videoStitching(clips [][]int, time int) int {
        const inf = math.MaxInt64 - 1
        dp := make([]int, time+1)
        for i := range dp {
            dp[i] = inf
        }
        dp[0] = 0
        for i := 1; i < len(dp); i++ {
            for _, clip := range clips {
                l, r := clip[0], clip[1]
                if i<=r && i>l && dp[i] > dp[l] +1 {
                    dp[i] = dp[l] + 1
                }
            }
        }
        if dp[time] == inf {
            return -1
        }
        return dp[time]
    }
    

    相关文章

      网友评论

          本文标题:1024. 视频拼接

          本文链接:https://www.haomeiwen.com/subject/oncdcrtx.html