@liji94188 Hi, thanks for your great solution, but I don't quite understand your explanation:

"according to palindrome string's property, when we trim both the head and tail characters of it ,we must get a palindrome string with length = currLength+1, which means in the previous round we got longest palindrome string with length = currLength+1"

Here is my simple understanding correct me if I am wrong:

it can not be i - currentMaxLength - 2 since if we can form a palindrome from the char that is currentMaxLength-2 ahead of i to i (i - currentMaxLength-2 to i) then this new palindrome has a length currentMaxLength + 3

How can you add 3 chars at either beginning or end of a palindrome to make another palindrome, correct ?

Thanks