This commit is contained in:
youngyangyang04
2022-03-23 16:13:01 +08:00
parent 759175ac6f
commit 77aa72b984
3 changed files with 3 additions and 4 deletions

View File

@@ -255,7 +255,7 @@ void getNext(int* next, const string& s)
1. 初始化:
定义两个指针i和j,j指向前缀起始位置,i指向后缀起始位置。
定义两个指针i和j,j指向前缀末尾位置,i指向后缀末尾位置。
然后还要对next数组进行初始化赋值,如下:

View File

@@ -156,11 +156,10 @@ dp[j] 表示:填满j(包括j)这么大容积的包,有dp[j]种方法
有哪些来源可以推出dp[j]呢?
填满容量为j - nums[i]的背包,有dp[j - nums[i]]种方法。
不考虑nums[i]的情况下,填满容量为j - nums[i]的背包,有dp[j - nums[i]]种方法。
那么只要搞到nums[i]的话,凑成dp[j]就有dp[j - nums[i]] 种方法。
例如:dp[j],j 为5,
* 已经有一个1(nums[i]) 的话,有 dp[4]种方法 凑成 dp[5]。