Check if all the palindromic sub | C # implementation of the approach ; Function to check if the string is palindrome ; Function that checks whether all the palindromic sub - strings are of odd length . ; Creating each substring ; If the sub - string is of even length and is a palindrome then , we return False ; Driver code
using System ; public class GFG { static bool checkPalindrome ( String s ) { for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] != s [ ( s . Length - i - 1 ) ] ) return false ; } return true ; } static bool CheckOdd ( String s ) { int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { String x = " " ; for ( int j = i ; j < n ; j ++ ) { x += s [ j ] ; if ( x . Length % 2 == 0 && checkPalindrome ( x ) == true ) return false ; } } return true ; } public static void Main ( ) { String s = " geeksforgeeks " ; if ( CheckOdd ( s ) ) Console . Write ( " YES " ) ; else Console . Write ( " NO " ) ; } }