Find All Palindromes
excerpt: Solution for one of the common string interview questions. tags: expand-to-the-left expand-to-the-right value-comparison pairwise-comparison
Given a string find all non-single letter substrings that are palindromes.
For each letter in the input string, expand to the left and right. Check for even and odd length palindromes during expansion. Move to the next letter if a palindrome does not exist.
Expand one character to the left and right and compare them. If both are equal, print out the palindrome substring.
|
|