Longest Palindromic Substring Solution
Question: Given a string s , return the longest palindromic substring in s . Example 1: Input: s = "babad" Output: "bab" Explanation: "aba" is also a valid answer. Example 2: Input: s = "cbbd" Output: "bb" Solution : Let us create a Table. If the string size is n, then the table will have n rows and n columns. The element a(i, j) of the table will determine whether the substring from index i to j is a palindrome or not. So in this way, we will calculate the maximum length of the palindromic substring. Now to fill this table we will use the following algorithm: STEP 1: Create a Table, Where the Row index is the start of the palindrome substring and the column index is the end of the palindromic substring. STEP 2: Fill the diagonal of the table with 1. Because (i, i) is itself a palindrome of length 1. STEP 3: Fill (i, i+1) by checking adjacent characters. If they are equal then 1, else 0. STEP 4: For every Distance other su...