human
Count smaller elements present in the array for each array element | Function to count for each array element , the number of elements that are smaller than that element.
Stores the frequencies of array elements.
Traverse the array.
Update frequency of arr [ i ].
Initialize sum with 0.
Compute prefix sum of the array hash [ ].
Traverse the array arr [ ].
If current element is 0.
Print the resultant count.
Driver Code"
Solution in Python:
assistant
#Here is code to count smaller elements present in the array for each array element and the other steps required.
 def smallerNumbers ( arr , N ) :
	hash = [ 0 ] * 100000
	for i in range ( N ) :
		hash [ arr [ i ] ] += 1
	sum = 0
	for i in range ( 1 , 100000 ) :
		hash [ i ] += hash [ i - 1 ]
	for i in range ( N ) :
		if ( arr [ i ] == 0 ) :
			print ( "0" )
			continue
		print ( hash [ arr [ i ] - 1 ] , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
	arr = [ 3 , 4 , 1 , 1 , 2 ]
	N = len ( arr )
	smallerNumbers ( arr , N )