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
- Count of Palindromic substrings in an Index range
- Check if a string contains a palindromic sub-string of even length
- 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
- Count number of distinct substrings of a given length
- 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
- 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
- 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
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.