![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
动态规划
动态规划的一些例题
jiangkun0331
Bugs总是让我们无法心安
展开
-
不同子序列
不同子序列(Distinct Subsequences)难度:Hard备注:出自leetcode题目描述Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (canbe none)原创 2020-08-03 23:13:54 · 240 阅读 · 0 评论 -
编辑距离
编辑距离(Edit Distance)难度:Hard备注:出自leetcode题目描述Given two words word1 and word2, find the minimum number of steps required to convert word1 toword2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:a) Insert a原创 2020-08-03 23:09:28 · 163 阅读 · 0 评论 -
回文串分割
回文串分割(Palindrome Partitioning)难度:Hard备注:回文串知识,出自leetcode题目描述Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s =“aab”, Return原创 2020-08-03 23:04:15 · 895 阅读 · 0 评论 -
背包问题
背包问题题目描述有 n 个物品和一个大小为 m 的背包. 给定数组 A 表示每个物品的大小和数组 V 表示每个物品的价值.问最多能装入背包的总价值是多大?背包问题状态:F(i, j): 前i个物品放入大小为j的背包中所获得的最大价值状态递推:对于第i个商品,有一种例外,装不下,两种选择,放或者不放如果装不下:此时的价值与前i-1个的价值是一样的F(i,j) = F(i-1,j)如果可以装入:需要在两种选择中找最大的F(i, j) = max{F(i-1,j), F(i-1, j -原创 2020-08-03 22:54:04 · 155 阅读 · 0 评论 -
最小路径和
最小路径和(Minimum Path Sum)难度:Medium备注:出自leetcode题目描述Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right whichminimizes the sum of all numbers along its path.Note: You can only move either down or right at any p原创 2020-08-03 22:49:02 · 134 阅读 · 0 评论 -
路径总数
路径总数(Unique Paths)难度:Easy备注:出自leetcode题目描述A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach thebottom-right原创 2020-08-03 22:44:58 · 850 阅读 · 0 评论 -
三角矩阵
三角矩阵(Triangle)难度:Medium备注:出自leetcode题目描述Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacentnumbers on the row below.For example, given the following triangle[ [2], [3,4], [6,5,7],[4,1,8,3]]Th原创 2020-08-03 22:37:08 · 1855 阅读 · 0 评论 -
字符串分割
字符串分割(Word Break)难度:Medium备注:出自leetcode题目描述Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separatedsequence of one or more dictionary words.For example, given s =“leetcode”, dict =[“leet”, “code”].Retur原创 2020-08-03 22:32:12 · 171 阅读 · 0 评论 -
斐波那契数列
Fibonacci难度:Easy备注:斐波那契数列,出自《剑指offer》题目描述大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0)。n<=39int Fibonacci(int n)来源:牛客-剑指Offer分析:斐波那契数列定义:F(n)=F(n-1)+F(n-2)(n>=2,n∈N*),其中F(1)=1,F(2)=1动态规划状态:F(n)状态递推:F(n)=F(n-1)+F(n-2)初始值:F(1)=F(2原创 2020-08-03 22:27:17 · 121 阅读 · 0 评论