Largest number in the Array having frequency same as value | Function to find the largest number whose frequency is equal to itself . ; Find the maximum element in the array ; Driver code
def findLargestNumber ( arr ) : NEW_LINE INDENT k = max ( arr ) ; NEW_LINE m = [ 0 ] * ( k + 1 ) ; NEW_LINE for n in arr : NEW_LINE INDENT m [ n ] += 1 ; NEW_LINE DEDENT for n in range ( len ( arr ) - 1 , 0 , - 1 ) : NEW_LINE INDENT if ( n == m [ n ] ) : NEW_LINE INDENT return n ; NEW_LINE DEDENT DEDENT return - 1 ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 3 , 2 , 5 , 2 , 4 , 5 ] ; NEW_LINE print ( findLargestNumber ( arr ) ) ; NEW_LINE DEDENT