S is string containing only lowercase English alphabets. We need to find if there exists at least one palindromic sub-string whose length is even.
Input : aassss Output : YES Input : gfg Output : NO
Notice that a palindrome of even length must contain two same alphabets in the middle. So we just need to check for this condition. If we find two consecutive same alphabets in the string then we output “YES” otherwise “NO”.
Below is the implementation:
# Python 3 program to check if there is
# a substring palindrome of even length.
# function to check if two consecutive
# same characters are present
for i in range (0, len(s)):
if (s[i] == s[i + 1]):
# Driver Code
s = “xzyyz”
# This code is contributed
# by iAyushRAJ
- Check if all the palindromic sub-strings are of odd length
- Find length of longest subsequence of one string which is substring of another string
- Number of strings of length N with no palindromic sub string
- Longest Palindromic Substring using Palindromic Tree | Set 3
- Convert to a string that is repetition of a substring of k length
- Maximum length substring with highest frequency in a string
- Minimum cuts required to convert a palindromic string to a different palindromic string
- Check if a string is substring of another
- Python | Check if a Substring is Present in a Given String
- Longest Palindromic Substring | Set 2
- Longest Palindromic Substring | Set 1
- Longest Non-palindromic substring
- Make palindromic string non-palindromic by rearranging its letters
- Suffix Tree Application 6 - Longest Palindromic Substring
- Check if a binary string contains all permutations of length k
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.