Palindromic Substrings — Expand Around Center
Count palindromic substrings. Expand around each center (n odd-length + n-1 even-length centers), count valid expansions.
webcoderspeed.com
8 articles
Count palindromic substrings. Expand around each center (n odd-length + n-1 even-length centers), count valid expansions.
Find longest palindromic subsequence length. 2D DP: if s[i]==s[j], dp[i][j] = dp[i+1][j-1]+2, else max of neighbors. Fill diagonally.
Find all index pairs forming palindromes by checking prefix/suffix splits against a reverse-word map.
Find pairs (i,j) where words[i]+words[j] is a palindrome. Insert reversed words into trie, for each word check palindromic suffix/prefix conditions.
Partition a string into all-palindrome substrings using backtracking with O(n^2) precomputed palindrome DP table for O(1) checks.
Find the longest palindromic substring in O(n) using Manacher's algorithm. Expands palindromes using a mirror trick to avoid redundant work.
Comprehensive palindrome problem coverage: valid palindrome check, longest palindromic substring (three methods), count palindromic substrings, and palindrome partitioning.
Add minimum characters to the front of a string to make it a palindrome. KMP trick: concatenate s + '#' + rev(s), find the LPS value at the last position.