更新图片链接
This commit is contained in:
6
problems/0392.判断子序列.md
Normal file → Executable file
6
problems/0392.判断子序列.md
Normal file → Executable file
@@ -80,7 +80,7 @@ if (s[i - 1] != t[j - 1]),此时相当于t要删除元素,t如果把当前
|
||||
因为这样的定义在dp二维矩阵中可以留出初始化的区间,如图:
|
||||
|
||||
|
||||

|
||||

|
||||
|
||||
如果要是定义的dp[i][j]是以下标i为结尾的字符串s和以下标j为结尾的字符串t,初始化就比较麻烦了。
|
||||
|
||||
@@ -98,14 +98,14 @@ vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1, 0));
|
||||
如图所示:
|
||||
|
||||
|
||||

|
||||

|
||||
|
||||
5. 举例推导dp数组
|
||||
|
||||
以示例一为例,输入:s = "abc", t = "ahbgdc",dp状态转移图如下:
|
||||
|
||||
|
||||

|
||||

|
||||
|
||||
dp[i][j]表示以下标i-1为结尾的字符串s和以下标j-1为结尾的字符串t 相同子序列的长度,所以如果dp[s.size()][t.size()] 与 字符串s的长度相同说明:s与t的最长相同子序列就是s,那么s 就是 t 的子序列。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user