Maximize the number of palindromic Strings | Java 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
class GFG { static int max_palindrome ( String [ ] s , int n ) { int flag = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] . length ( ) % 2 != 0 ) { flag = 1 ; } } if ( flag == 1 ) { return n ; } int z = 0 ; int o = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < s [ i ] . length ( ) ; j ++ ) { if ( s [ i ] . charAt ( j ) == '0' ) z += 1 ; else o += 1 ; } } if ( o % 2 == 0 && z % 2 == 0 ) { return n ; } else { return n - 1 ; } } public static void main ( String [ ] args ) { int n = 3 ; String s [ ] = { "1110" , "100110" , "010101" } ; System . out . println ( max_palindrome ( s , n ) ) ; } }