Check given string is oddly palindrome or not | C # program for the above approach ; Function to check if the String str is palindromic or not ; Iterate the String str from left and right pointers ; Keep comparing characters while they are same ; If they are not same then return false ; Return true if the String is palindromic ; Function to make String using odd indices of String str ; Functions checks if characters at odd index of the String forms palindrome or not ; Make odd indexed String ; Check for Palindrome ; Driver code ; Given String ; Function Call
using System ; class GFG { static bool isPalindrome ( string str ) { int l = 0 ; int h = str . Length - 1 ; while ( h > l ) { if ( str [ l ] != str [ h ] ) { return false ; } l ++ ; h -- ; } return true ; } static string makeOddString ( string str ) { string odd = " " ; for ( int i = 1 ; i < str . Length ; i += 2 ) { odd += str [ i ] ; } return odd ; } static void checkOddlyPalindrome ( string str ) { string odd = makeOddString ( str ) ; if ( isPalindrome ( odd ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } static void Main ( ) { string str = " ddwfefwde " ; checkOddlyPalindrome ( str ) ; } }