Minimum number of operations on a binary string such that it gives 10 ^ A as remainder when divided by 10 ^ B | C # implementation of the approach ; 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
using System ; class GFG { static int findCount ( string s , int n , int a , int b ) { int res = 0 ; for ( int i = 0 ; i < b ; i ++ ) { if ( i == a ) { if ( s [ n - i - 1 ] != '1' ) res += 1 ; } else { if ( s [ n - i - 1 ] != '0' ) res += 1 ; } } return res ; } static public void Main ( ) { string str = "1001011001" ; int N = str . Length ; int A = 3 , B = 6 ; Console . WriteLine ( findCount ( str , N , A , B ) ) ; } }