Given a string ‘s’ check if all of its palindromic sub-strings are of odd length or not. If yes then print “YES” or “NO” otherwise.
Input: str = “geeksforgeeks”
Since, “ee” is a palindromic sub-string of even length.
Input: str = “madamimadam”
Approach: Simply, iterate over each sub-string of ‘s’ and check if it is a palindrome. If it is a palindrome then it must of odd length.
Below is the implementation of the above approach:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Count all Prime Length Palindromic Substrings
- Check if an array has some palindromic subsequence of length at least 3
- Count of Palindromic substrings in an Index range
- Lexicographically all Shortest Palindromic Substrings from a given string
- Length of longest Palindromic Subsequence of even length with no two adjacent characters same
- Check if a string contains a palindromic sub-string of even length
- Rearrange the string to maximize the number of palindromic substrings
- Permutation of given string that maximizes count of Palindromic substrings
- Contiguous unique substrings with the given length L
- Number of palindromic subsequences of length k where k <= 3
- Sum of all odd length palindromic numbers within the range [L, R]
- Count number of distinct substrings of a given length
- Convert all substrings of length 'k' from base 'b' to decimal
- Length of longest palindromic sub-string : Recursion
- Smallest Palindromic Subsequence of Even Length in Range [L, R]
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.