text: Count of distinct possible pairs such that the element from A is greater than the element from B | Function to return the count of pairs ; Driver Code
code: function countPairs ( A , B ) { let n = A . length ; let ans = 0 ; A . sort ( ) ; B . sort ( ) ; for ( let i = 0 ; i < n ; i ++ ) { if ( A [ i ] > B [ ans ] ) { ans ++ ; } } return ans ; } let A = [ 30 , 28 , 45 , 22 ] ; let B = [ 35 , 25 , 22 , 48 ] ; document . write ( countPairs ( A , B ) ) ;