Count minimum bits to flip such that XOR of A and B equal to C | Javascript 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 ; N represent total count of Bits
function totalFlips ( A , B , C , N ) { let count = 0 ; for ( let i = 0 ; i < N ; ++ i ) { if ( A [ i ] == B [ i ] && C [ i ] == ' ' ) ++ count ; else if ( A [ i ] != B [ i ] && C [ i ] == ' ' ) ++ count ; } return count ; } let N = 5 ; let a = " " ; let b = " " ; let c = " " ; document . write ( totalFlips ( a , b , c , N ) ) ;