Skip to content

Commit 05164ed

Browse files
committed
将最长回文子序列的图片文件夹改为英文
1 parent 88b0b8a commit 05164ed

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

dynamic_programming/StrategiesForSubsequenceProblem.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Now let's talk about the Longest Palindrome Subsequence (LPS) problem to explain
7373

7474
We have solve the "Longest Palindrome Substring" problem before. This time, the difficulty is increased by finding the length of the Longest Palindrome Subsequence instead of substring:
7575

76-
![](../pictures/最长回文子序列/1.jpg)
76+
![](../pictures/subsequence/1.jpg)
7777

7878
In this question, **we define `dp[i][j]` as the length of the longest palindrome subsequence within the substring `s[i..j]`**. Please remember this definition so as to understand the algorithm.
7979

@@ -83,19 +83,19 @@ Specifically, if we want to find `dp[i][j]`, suppose you have already got the re
8383

8484

8585

86-
![](../pictures/最长回文子序列/1.jpg)
86+
![](../pictures/subsequence/1.jpg)
8787

8888
The answer is yes! It depends on the characters of `s[i]` and `s[j]`:
8989

9090
**If they are equal**, then the longest palindrome subsequence in `s[i+1..j-1]` would be these two characters plus the longest palindrome subsequence in `s[i..j]`:
9191

9292

9393

94-
![](../pictures/最长回文子序列/2.jpg)
94+
![](../pictures/subsequence/2.jpg)
9595

9696
**If they are not equal**, it means that they **cannot appear at the same time** in the longest palindrome subsequence of `s[i..j]`. Therefore, we add them **separately** to `s[i+1..j-1] ` to see which substring produces a longer palindrome subsequence:
9797

98-
![](../pictures/最长回文子序列/3.jpg)
98+
![](../pictures/subsequence/3.jpg)
9999

100100
The code of the above two cases can be written like this:
101101

@@ -118,9 +118,9 @@ Since `i`must be less than or equal to `j`, for those locations where `i > j`, t
118118

119119
In addition, look at the state transition equation we just got. To find `dp[i][j]`, you need to know `dp[i+1][j-1]`, `dp[i+1][j]` and`dp[i][j -1]` these three values. And look at the base case we determined, this is how the DP array looks like after being filled:
120120

121-
![](../pictures/最长回文子序列/4.jpg)
121+
![](../pictures/subsequence/4.jpg)
122122

123-
**In order to guarantee that before each calculation of `dp[i][j]`, the values in the left, down and right direction have been calculated, we can only traverse it diagonally or reversely**:![](../pictures/最长回文子序列/5.jpg)
123+
**In order to guarantee that before each calculation of `dp[i][j]`, the values in the left, down and right direction have been calculated, we can only traverse it diagonally or reversely**:![](../pictures/subsequence/5.jpg)
124124

125125
Here I choose to traverse reversely. The code is as follows:
126126

0 commit comments

Comments
 (0)