Palindrome pair in an array of words ( or strings ) | C # program to find if there is a pair that can form a palindrome . ; Utility function to check if a string is a palindrome ; compare each character from starting with its corresponding character from last ; Function to check if a palindrome pair exists ; Consider each pair one by one ; concatenate both strings ; check if the concatenated string is palindrome ; check if the concatenated string is palindrome ; Driver code
using System ; using System . Collections . Generic ; class GFG { static Boolean isPalindrome ( String str ) { int len = str . Length ; for ( int i = 0 ; i < len / 2 ; i ++ ) if ( str [ i ] != str [ len - i - 1 ] ) return false ; return true ; } static Boolean checkPalindromePair ( List < String > vect ) { for ( int i = 0 ; i < vect . Count - 1 ; i ++ ) { for ( int j = i + 1 ; j < vect . Count ; j ++ ) { String check_str = " " ; check_str = check_str + vect [ i ] + vect [ j ] ; if ( isPalindrome ( check_str ) ) return true ; check_str = vect [ j ] + vect [ j ] ; if ( isPalindrome ( check_str ) ) return true ; } } return false ; } public static void Main ( String [ ] args ) { List < String > vect = new List < String > ( ) { " geekf " , " geeks " , " or " , " keeg " , " abc " , " bc " } ; if ( checkPalindromePair ( vect ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }