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:
- Count all Prime Length Palindromic Substrings
- Check if a string contains a palindromic sub-string of even length
- Count of Palindromic substrings in an Index range
- Rearrange the string to maximize the number of palindromic substrings
- Sum of all odd length palindromic numbers within the range [L, R]
- Number of palindromic subsequences of length k where k <= 3
- Contiguous unique substrings with the given length L
- Number of strings of length N with no palindromic sub string
- Count number of distinct substrings of a given length
- Convert all substrings of length 'k' from base 'b' to decimal
- Maximum length palindromic substring such that it starts and ends with given char
- Find number of substrings of length k whose sum of ASCII value of characters is divisible by k
- Make palindromic string non-palindromic by rearranging its letters
- Longest Palindromic Substring using Palindromic Tree | Set 3
- Minimum cuts required to convert a palindromic string to a different palindromic 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.