Minimum number of operations on a binary string such that it gives 10 ^ A as remainder when divided by 10 ^ B | Function to return the minimum number of operations on a binary string such that it gives 10 ^ A as remainder when divided by 10 ^ B ; Initialize result ; Loop through last b digits ; Driver code
function findCount ( s , n , a , b ) { var res = 0 ; for ( var i = 0 ; i < b ; i ++ ) { if ( i == a ) res += ( s [ n - i - 1 ] != ' ' ) ; else res += ( s [ n - i - 1 ] != ' ' ) ; } return res ; } var str = " " ; var N = str . length ; var A = 3 , B = 6 ; document . write ( findCount ( str , N , A , B ) ) ;