From 4760924db0d9d5f53719ed36fe0b3d201cfb3c6f Mon Sep 17 00:00:00 2001 From: jinbudaily <18336218010@163.com> Date: Wed, 26 Jul 2023 16:25:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=200516.=E6=9C=80=E9=95=BF?= =?UTF-8?q?=E5=9B=9E=E6=96=87=E5=AD=90=E5=BA=8F=E5=88=97=200647.=E5=9B=9E?= =?UTF-8?q?=E6=96=87=E5=AD=90=E4=B8=B2=20=E5=8A=A8=E6=80=81=E8=A7=84?= =?UTF-8?q?=E5=88=92=E6=80=BB=E7=BB=93=20=E6=8E=92=E7=89=88=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0516.最长回文子序列.md | 13 ++++++------- problems/0647.回文子串.md | 21 +++++++++++++-------- problems/动态规划总结篇.md | 1 + 3 files changed, 20 insertions(+), 15 deletions(-) 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 @@ +