human
Write me a code to count pairs ( i , j ) from given array such that i K * arr [ j ] and the other steps required given the following:
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"
How can the above be solved in Python?
assistant
#Here is code to count pairs ( i , j ) from given array such that i K * arr [ j ] and the other steps required.
 def getPairs ( arr , N , K ) :
	count = 0
	for i in range ( N ) :
		for j in range ( i + 1 , N ) :
			if ( arr [ i ] > K * arr [ i + 1 ] ) :
				count += 1
	print ( count )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 5 , 6 , 2 , 1 ]
	N = len ( arr )
	K = 2
	getPairs ( arr , N , K )