text: Maximum frequency of a remainder modulo 2 i | Binary representation of the digits ; Function to return the maximum frequency of s modulo with a power of 2 ; Store the binary representation ; Convert the octal to binary ; Remove the LSB ; If there is 1 in the binary representation ; Find the number of zeroes in between two 1 's in the binary representation ; Driver code
code: bin = [ " " , " " , " " , " " , " " , " " , " " , " " ] ; function maxFreq ( s ) { var binary = " " ; for ( var i = 0 ; i < s . length ; i ++ ) { binary += bin [ s . charAt ( i ) - ' ' ] ; } binary = binary . substr ( 0 , binary . length - 1 ) ; var count = 1 , prev = - 1 , i , j = 0 ; for ( i = binary . length - 1 ; i >= 0 ; i -- , j ++ ) if ( binary . charAt ( i ) == ' ' ) { count = Math . max ( count , j - prev ) ; prev = j ; } return count ; } var octal = " " ; document . write ( maxFreq ( octal ) ) ;