text: Maximum frequency of a remainder modulo 2 i | C # implementation of the approach ; 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: using System ; class GFG { static String [ ] bin = { "000" , "001" , "010" , "011" , "100" , "101" , "110" , "111" } ; static int maxFreq ( String s ) { String binary = " " ; for ( int K = 0 ; K < s . Length ; K ++ ) { binary += bin [ s [ K ] - '0' ] ; } binary = binary . Substring ( 0 , binary . Length - 1 ) ; int count = 1 , prev = - 1 , i , j = 0 ; for ( i = binary . Length - 1 ; i >= 0 ; i -- , j ++ ) if ( binary [ i ] == '1' ) { count = Math . Max ( count , j - prev ) ; prev = j ; } return count ; } public static void Main ( String [ ] args ) { String octal = "13" ; Console . WriteLine ( maxFreq ( octal ) ) ; } }