Check if both halves of the string have at least one different character | Function which break string into two halves Sorts the two halves separately Compares the two halves return true if any index has non - zero value ; Declaration and initialization of counter array ; Driver code
function Function ( str ) { let l = str . length ; str = ( str . slice ( 0 , Math . floor ( l / 2 ) ) . sort ( ) ) . concat ( str . slice ( Math . floor ( l / 2 ) , l ) . sort ( ) ) ; for ( let i = 0 ; i < Math . floor ( l / 2 ) ; i ++ ) if ( str [ i ] != str [ Math . floor ( l / 2 ) + i ] ) return true ; return false ; } let str = " " . split ( " " ) ; if ( Function ( str ) ) document . write ( " " + " " ) ; else document . write ( " " + " " ) ;