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:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Check if a string can be split into even length palindromic substrings
- Count all Prime Length Palindromic Substrings
- Check if an array has some palindromic subsequence of length at least 3
- 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
- Lexicographically all Shortest Palindromic Substrings from a given string
- Count of K-size substrings having palindromic permutations
- Count of Palindromic substrings in an Index range
- Permutation of given string that maximizes count of Palindromic substrings
- Rearrange the string to maximize the number of palindromic substrings
- Contiguous unique substrings with the given length L
- Sum of all odd length palindromic numbers within the range [L, R]
- Number of palindromic subsequences of length k where k <= 3
- Count number of distinct substrings of a given length
- Count of substrings of length K with exactly K distinct characters
- Convert all substrings of length 'k' from base 'b' to decimal
- Smallest Palindromic Subsequence of Even Length in Range [L, R]
- Length of longest palindromic sub-string : Recursion
- Count of non-palindromic strings of length M using given N characters
- Number of strings of length N with no palindromic sub string
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.