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:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if a string can be split into even length palindromic substrings
- Count all Prime Length Palindromic Substrings
- Sum of all odd length palindromic numbers within the range [L, R]
- Check if a Palindromic String can be formed by concatenating Substrings of two given Strings
- Check if a palindromic string can be obtained by concatenating substrings split from same indices of two given strings
- Lexicographically all Shortest Palindromic Substrings from a given string
- Count of odd length contiguous Palindromic sequences in a Matrix
- Check if all substrings of length K of a Binary String has equal count of 0s and 1s
- Length of longest Palindromic Subsequence of even length with no two adjacent characters same
- Longest Palindromic Substring using Palindromic Tree | Set 3
- Make palindromic string non-palindromic by rearranging its letters
- Minimum cuts required to convert a palindromic string to a different palindromic string
- Generate a String of having N*N distinct non-palindromic Substrings
- 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
- Count of K-size substrings having palindromic permutations
- Split string into three palindromic substrings with earliest possible cuts
- Check if a string contains a palindromic sub-string of even length
- Check if an array has some palindromic subsequence of length at least 3
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.