Get max size and reverse each string Since we have to perform XOR operation on bits from right to left Reversing the string will make it easier to perform operation from left to right
for ( var i = 0 ; i < n ; i ++ ) { max_len = Math . max ( max_len , arr [ i ] . length ) ; arr [ i ] = arr [ i ] . split ( ' ' ) . reverse ( ) . join ( ' ' ) ; } for ( var i = 0 ; i < n ; i ++ ) {