Leetcode 5 - Longest palindromic substring

Note:

• My guts tell me this is a DP question.
• DP[i][j] means whether substring from i to j is a palindrome.
• Use i and j to represent start and end of a substring.
• Note that dp[i][j] is true when dp[i+1][j-1] is true.
• Run time O(n^2).

Question:

Given a string s, return the longest palindromic substring in s.

Example:

Code: