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
- Number of palindromic subsequences of length k where k <= 3
- Sum of all odd length palindromic numbers within the range [L, R]
- 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
- Find Nth even length palindromic number formed using digits X and Y
- 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
- Check whether all the substrings have number of vowels atleast as that of consonants
- Make palindromic string non-palindromic by rearranging its letters
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.