Check if a string contains a palindromic sub | C ++ program to check if there is a substring palindrome of even length . ; function to check if two consecutive same characters are present ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool check ( string s ) { for ( int i = 0 ; i < s . length ( ) - 1 ; i ++ ) if ( s [ i ] == s [ i + 1 ] ) return true ; return false ; } int main ( ) { string s = " xzyyz " ; if ( check ( s ) ) cout << " YES " << endl ; else cout << " NO " << endl ; return 0 ; }