rewrite leetcode longest palindromic substring