diff --git a/problems/0516.最长回文子序列.md b/problems/0516.最长回文子序列.md index fcdd57b0..80927583 100644 --- a/problems/0516.最长回文子序列.md +++ b/problems/0516.最长回文子序列.md @@ -152,8 +152,7 @@ public: ## 其他语言版本 - -Java: +### Java: ```java public class Solution { @@ -175,8 +174,7 @@ public class Solution { } ``` - -Python: +### Python: ```python class Solution: @@ -193,7 +191,7 @@ class Solution: return dp[0][-1] ``` -Go: +### Go: ```Go func longestPalindromeSubseq(s string) int { @@ -222,7 +220,7 @@ func longestPalindromeSubseq(s string) int { } ``` -Javascript: +### Javascript: ```javascript const longestPalindromeSubseq = (s) => { @@ -247,7 +245,7 @@ const longestPalindromeSubseq = (s) => { }; ``` -TypeScript: +### TypeScript: ```typescript function longestPalindromeSubseq(s: string): number { @@ -281,3 +279,4 @@ function longestPalindromeSubseq(s: string): number { + diff --git a/problems/0647.回文子串.md b/problems/0647.回文子串.md index 084b9f74..fdf83736 100644 --- a/problems/0647.回文子串.md +++ b/problems/0647.回文子串.md @@ -26,11 +26,13 @@ 提示:输入的字符串长度不会超过 1000 。 -## 暴力解法 +## 思路 + +### 暴力解法 两层for循环,遍历区间起始位置和终止位置,然后还需要一层遍历判断这个区间是不是回文。所以时间复杂度:O(n^3) -## 动态规划 +### 动态规划 动规五部曲: @@ -187,7 +189,7 @@ public: * 时间复杂度:O(n^2) * 空间复杂度:O(n^2) -## 双指针法 +### 双指针法 动态规划的空间复杂度是偏高的,我们再看一下双指针法。 @@ -231,7 +233,7 @@ public: ## 其他语言版本 -Java: +### Java: 动态规划: @@ -337,7 +339,7 @@ class Solution { } ``` -Python: +### Python: > 动态规划: ```python @@ -390,7 +392,8 @@ class Solution: return res ``` -Go: +### Go: + ```Go func countSubstrings(s string) int { res:=0 @@ -416,7 +419,8 @@ func countSubstrings(s string) int { } ``` -Javascript +### Javascript: + > 动态规划 ```javascript const countSubstrings = (s) => { @@ -462,7 +466,7 @@ const countSubstrings = (s) => { } ``` -TypeScript: +### TypeScript: > 动态规划: @@ -524,3 +528,4 @@ function expandRange(s: string, left: number, right: number): number { + diff --git a/problems/动态规划总结篇.md b/problems/动态规划总结篇.md index 8a1531f8..c86376d3 100644 --- a/problems/动态规划总结篇.md +++ b/problems/动态规划总结篇.md @@ -136,3 +136,4 @@ +