Count minimum bits to flip such that XOR of A and B equal to C | Java code to count the Minimum bits in A and B ; If both A [ i ] and B [ i ] are equal ; If Both A and B are unequal ; driver code ; N represent total count of Bits
class GFG { static int totalFlips ( String A , String B , String C , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; ++ i ) { if ( A . charAt ( i ) == B . charAt ( i ) && C . charAt ( i ) == '1' ) ++ count ; else if ( A . charAt ( i ) != B . charAt ( i ) && C . charAt ( i ) == '0' ) ++ count ; } return count ; } public static void main ( String [ ] args ) { int N = 5 ; String a = "10100" ; String b = "00010" ; String c = "10011" ; System . out . print ( totalFlips ( a , b , c , N ) ) ; } }