Skip to content

update #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion problems/5.longest-palindromic-substring.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ https://leetcode-cn.com/problems/longest-palindromic-substring/

解决这类问题的核心思想就是两个字“延伸”,具体来说

- 如果一个字符串是回文串,那么在它左右分别加上一个相同的字符,那么它一定还是一个回文串
- 如果在一个不是回文字符串的字符串两端添加任何字符,或者在回文串左右分别加不同的字符,得到的一定不是回文串
- 如果一个字符串不是回文串,或者在回文串左右分别加不同的字符,得到的一定不是回文串

事实上,上面的分析已经建立了大问题和小问题之间的关联,
Expand Down Expand Up @@ -118,6 +118,17 @@ var longestPalindrome = function(s) {
};
```


***复杂度分析***
- 时间复杂度:$O(N^2)$
- 空间复杂度:$O(N^2)$

更多题解可以访问我的LeetCode题解仓库:https://github.com/azl397985856/leetcode 。 目前已经30K star啦。

大家也可以关注我的公众号《脑洞前端》获取更多更新鲜的LeetCode题解

![](https://pic.leetcode-cn.com/89ef69abbf02a2957838499a96ce3fbb26830aae52e3ab90392e328c2670cddc-file_1581478989502)

## 相关题目

- [516.longest-palindromic-subsequence](./516.longest-palindromic-subsequence.md)