Maximize the number of palindromic Strings | Javascript program for the above approach ; To check if there is any string of odd length ; If there is at least 1 string of odd length . ; If all the strings are of even length . ; Count of 0 's in all  the strings ; Count of 1 's in  all the strings ; If z is even and o is even then ans will be N . ; Otherwise ans will be N - 1. ; Driver code
function max_palindrome ( s , n ) { let flag = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( s [ i ] . length % 2 != 0 ) { flag = 1 ; } } if ( flag == 1 ) { return n ; } let z = 0 ; let o = 0 ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < s [ i ] . length ; j ++ ) { if ( s [ i ] [ j ] == ' ' ) z += 1 ; else o += 1 ; } } if ( o % 2 == 0 && z % 2 == 0 ) { return n ; } else { return n - 1 ; } } let n = 3 ; let s = [ " " , " " , " " ] ; document . write ( max_palindrome ( s , n ) ) ;