天天看点

LeetCode5:Longest Palindromic Substring

题目:

given a string s, find the longest palindromic substring in s.

you may assume that the maximum length of s is 1000, and there exists one

unique longest palindromic substring.

解题思路:

主要有三种:

第一种:manacher算法,也是最快的,时间复杂度为o(n)

第二种:dp算法,时间复杂度为o(n*n)

第三种:中心法,时间复杂度为o(n*n)

实现代码: