mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-06 15:09:40 +08:00
Update
This commit is contained in:
@ -255,7 +255,7 @@ void getNext(int* next, const string& s)
|
||||
|
||||
1. 初始化:
|
||||
|
||||
定义两个指针i和j,j指向前缀起始位置,i指向后缀起始位置。
|
||||
定义两个指针i和j,j指向前缀末尾位置,i指向后缀末尾位置。
|
||||
|
||||
然后还要对next数组进行初始化赋值,如下:
|
||||
|
||||
|
@ -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]。
|
||||
|
Reference in New Issue
Block a user