Character whose frequency is equal to the sum of frequencies of other characters of the given string | Function that returns true if some character exists in the given string whose frequency is equal to the sum frequencies of other characters of the string ; If string is of odd length ; To store the frequency of each character of the string ; Update the frequencies of the characters ; No such character exists ; Driver code
function isFrequencyEqual ( str , len ) { if ( len % 2 == 1 ) return false ; var i , freq = Array ( 26 ) . fill ( 0 ) ; for ( i = 0 ; i < len ; i ++ ) freq [ str [ i ] - ' ' ] ++ ; for ( i = 0 ; i < 26 ; i ++ ) if ( freq [ i ] == parseInt ( len / 2 ) ) return true ; return false ; } var str = " " ; var len = str . length ; if ( isFrequencyEqual ( str , len ) ) document . write ( " " ) ; else document . write ( " " ) ;