human
Noble integers in an array ( count of greater elements is equal to value ) | Python3 code to find Noble elements in an array.
Return a Noble element if present before last.
In case of duplicates we reach last occurrence here.
Driver code"
Solution in Python:
 ... Write me a code to noble integers in an array ( count of greater elements is equal to value ) and the other steps required?
assistant
#Here is code to noble integers in an array ( count of greater elements is equal to value ) and the other steps required.
 def nobleInteger ( arr ) :
	arr . sort ( )
	n = len ( arr )
	for i in range ( n - 1 ) :
		if arr [ i ] == arr [ i + 1 ] :
			continue
		if arr [ i ] == n - i - 1 :
			return arr [ i ]
	if arr [ n - 1 ] == 0 :
		return arr [ n - 1 ]
	return - 1
arr = [ 10 , 3 , 20 , 40 , 2 ]
res = nobleInteger ( arr )
if res != - 1 :
	print ( " The ▁ noble ▁ integer ▁ is " , res )
else :
	print ( " No ▁ Noble ▁ Integer ▁ Found " )