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
- Convert all substrings of length 'k' from base 'b' to decimal
- Number of strings of length N with no palindromic sub string
- Find number of substrings of length k whose sum of ASCII value of characters is divisible by k
- Longest Palindromic Substring using Palindromic Tree | Set 3
- Check if a binary string contains all permutations of length k
- Check length of a string is equal to the number appended at its last
- Check If every group of a's is followed by a group of b's of same length
- Palindromic Primes
- Count substrings with same first and last characters
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.