text: Check if a string can be split into even length palindromic substrings | 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 ; Given string ; Function Call
code: function check ( s , n ) { var st = [ ] ; for ( var i = 0 ; i < n ; i ++ ) { if ( st . length != 0 && st [ st . length - 1 ] == s [ i ] ) st . pop ( ) ; else st . push ( s [ i ] ) ; } if ( st . length == 0 ) { return true ; } else { return false ; } } var str = " " ; var n = str . length ; if ( check ( str , n ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }