Find pair with maximum ratio in an Array | Function to find the maximum pair possible for the array ; Loop to iterate over every possible pair in the array ; Check pair ( x , y ) as well as ( y , x ) for maximum value ; Update the answer ; Driver Code
def computeMaxValue ( arr , n ) : NEW_LINE INDENT ans = 0 NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT val = max ( arr [ i ] / arr [ j ] , arr [ j ] / arr [ i ] ) NEW_LINE ans = max ( ans , val ) NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT arr = [ 15 , 10 , 3 , 2 ] NEW_LINE n = len ( arr ) NEW_LINE print ( computeMaxValue ( arr , n ) ) NEW_LINE DEDENT