text: Check if a string can be split into even length palindromic substrings | C # program for the above approach ; Function to check String str can be split a String into even length palindromic subStrings ; Initialize a stack ; Iterate the String ; If the i - th character is same as that at the top of the stack then pop the top element ; Else push the current charactor into the stack ; If the stack is empty , then even palindromic subStrings are possible ; Else not - possible ; Driver Code ; Given String ; Function call
code: using System ; using System . Collections . Generic ; class GFG { static bool check ( String s , int n ) { Stack < int > st = new Stack < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( st . Count != 0 && st . Peek ( ) == s [ i ] ) st . Pop ( ) ; else st . Push ( s [ i ] ) ; } if ( st . Count == 0 ) { return true ; } else { return false ; } } public static void Main ( String [ ] args ) { String str = " aanncddc " ; int n = str . Length ; if ( check ( str , n ) ) { Console . Write ( " Yes " + " STRNEWLINE " ) ; } else { Console . Write ( " No " + " STRNEWLINE " ) ; } } }