Count pairs with Bitwise XOR greater than both the elements of the pair | Function that counts the pairs whose Bitwise XOR is greater than both the elements of pair ; Stores the count of pairs ; Generate all possible pairs ; Find the Bitwise XOR ; Find the maximum of two ; If xo < mx , increment count ; Prvar the value of count ; Driver Code ; Function Call
function countPairs ( A , N ) { var count = 0 ; for ( i = 0 ; i < N ; i ++ ) { for ( j = i + 1 ; j < N ; j ++ ) { var xo = ( A [ i ] ^ A [ j ] ) ; var mx = Math . max ( A [ i ] , A [ j ] ) ; if ( xo > mx ) { count ++ ; } } } document . write ( count ) ; } var arr = [ 2 , 4 , 3 ] ; var N = arr . length ; countPairs ( arr , N ) ;