human
Find K for every Array element such that at least K prefixes are â ‰¥ K | Function to find the K - value for every index in the array.
Multiset to store the array in the form of red - black tree.
Iterating over the array.
Inserting the current value in the multiset.
Condition to check if the smallest value in the set is less than it 's size.
Erase the smallest value.
h - index value will be the size of the multiset.
Driver Code.
Array.
Size of the array.
Function call"
How can the above be solved in Python?

Write me a code to find K for every Array element such that at least K prefixes are â ‰¥ K and the other steps required?
assistant
#Here is code to find K for every Array element such that at least K prefixes are â ‰¥ K and the other steps required.
 def print_h_index ( arr , N ) :
	ms = [ ]
	for i in range ( N ) :
		ms . append ( arr [ i ] )
		ms . sort ( )
		if ( ms [ 0 ] < len ( ms ) ) :
			ms . pop ( 0 )
		print ( len ( ms ) , end = ' ▁ ' )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 9 , 10 , 7 , 5 , 0 , 10 , 2 , 0 ]
	N = len ( arr )
	print_h_index ( arr , N )