text: Count pairs ( i , j ) from given array such that i K * arr [ j ] | Function to find the count required pairs ; Stores count of pairs ; Traverse the array ; Check if the condition is satisfied or not ; Driver Code ; Function Call
code: function getPairs ( arr , N , K ) { let count = 0 ; for ( let i = 0 ; i < N ; i ++ ) { for ( let j = i + 1 ; j < N ; j ++ ) { if ( arr [ i ] > K * arr [ i + 1 ] ) count ++ ; } } document . write ( count ) ; } let arr = [ 5 , 6 , 2 , 1 ] ; let N = arr . length ; let K = 2 ; getPairs ( arr , N , K ) ;