From 78bcffd3e4117b6da337d8cfdfe9961532099137 Mon Sep 17 00:00:00 2001 From: zzzkl Date: Tue, 4 Jan 2022 09:36:29 +0800 Subject: [PATCH] Update 0005.Longest-Palindromic-Substring.md --- .../ChapterFour/0001~0099/0005.Longest-Palindromic-Substring.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/content/ChapterFour/0001~0099/0005.Longest-Palindromic-Substring.md b/website/content/ChapterFour/0001~0099/0005.Longest-Palindromic-Substring.md index c8952865..1adffa4b 100644 --- a/website/content/ChapterFour/0001~0099/0005.Longest-Palindromic-Substring.md +++ b/website/content/ChapterFour/0001~0099/0005.Longest-Palindromic-Substring.md @@ -61,7 +61,7 @@ Output: "a" ![https://img.halfrost.com/Leetcode/leetcode_5_2.png](https://img.halfrost.com/Leetcode/leetcode_5_2.png) -- 核心部分是如何通过左边已经扫描过的数据推出右边下一次要扩散的中心。这里定义下一次要扩散的中心下标是 `i`。如果 `i` 比 `maxRight` 要小,只能继续中心扩散。如果 `i` 比 `maxRight` 大,这是又分为 3 种情况。三种情况见上图。将上述 3 种情况总结起来,就是 :`dp[i] = min(maxRight-i, dp[2*center-i])`,其中,`mirror` 相对于 `center` 是和 `i` 中心对称的,所以它的下标可以计算出来是 `2*center-i`。更新完 `dp[i]` 以后,就要进行中心扩散了。中心扩散以后动态维护最长回文串并相应的更新 `center`,`maxRight`,并且记录下原始字符串的起始位置 `begin` 和 `maxLen`。 +- 核心部分是如何通过左边已经扫描过的数据推出右边下一次要扩散的中心。这里定义下一次要扩散的中心下标是 `i`。如果 `i` 比 `maxRight` 要大,只能继续中心扩散。如果 `i` 比 `maxRight` 小,这时又分为 3 种情况。三种情况见上图。将上述 3 种情况总结起来,就是 :`dp[i] = min(maxRight-i, dp[2*center-i])`,其中,`mirror` 相对于 `center` 是和 `i` 中心对称的,所以它的下标可以计算出来是 `2*center-i`。更新完 `dp[i]` 以后,就要进行中心扩散了。中心扩散以后动态维护最长回文串并相应的更新 `center`,`maxRight`,并且记录下原始字符串的起始位置 `begin` 和 `maxLen`。 ## 代码