human
Count greater elements on the left side of every array element | Function to print the count of greater elements on left of each array element.
Function to get the count of greater elements on left of each array element.
Store distinct array elements in sorted order.
Stores the count of greater elements on the left side.
Traverse the array.
Insert array elements into the set.
Find previous greater element.
Find the distance between the previous greater element of arr [ i ] and last element of the set.
Driver code"
Solution in Python:
assistant
#Here is code to count greater elements on the left side of every array element and the other steps required.
 def display ( countLeftGreater , N ) :
	for i in range ( N ) :
		print ( countLeftGreater [ i ] , end = " ▁ " )
def countGreater ( arr , N ) :
	St = set ( )
	countLeftGreater = [ 0 ] * ( N )
	for i in range ( N ) :
		St . add ( arr [ i ] )
		it = 0
		for st in St :
			if ( arr [ i ] < st ) :
				break
			it += 1
		countLeftGreater [ i ] = abs ( it - len ( St ) )
	display ( countLeftGreater , N )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 12 , 1 , 2 , 3 , 0 , 11 , 4 ]
	N = len ( arr )
	countGreater ( arr , N )