Skip to content

Commit

Permalink
Merge pull request #3 from azl397985856/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
suukii authored May 21, 2020
2 parents e5634e7 + 7330d01 commit bec61ef
Showing 1 changed file with 12 additions and 1 deletion.
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)

0 comments on commit bec61ef

Please sign in to comment.