Maximize profit that can be earned by selling an item among N buyers |  ; ''Function to find the maximum profit earned by selling an item among N buyers ; '' Stores the maximum profit ; '' Stores the price of the item ; '' Traverse the array ; '' Count of buyers with  budget >= arr[i] ; '' Increment count ; '' Update the maximum profit ; '' Return the maximum possible  price ; ''Driver code
import sys NEW_LINE def maximumProfit ( arr , n ) : NEW_LINE INDENT ans = - sys . maxsize - 1 NEW_LINE price = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT count = 0 NEW_LINE for j in range ( n ) : NEW_LINE INDENT if ( arr [ i ] <= arr [ j ] ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT if ( ans < count * arr [ i ] ) : NEW_LINE INDENT price = arr [ i ] NEW_LINE ans = count * arr [ i ] NEW_LINE DEDENT DEDENT return price ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 22 , 87 , 9 , 50 , 56 , 43 ] NEW_LINE print ( maximumProfit ( arr , 6 ) ) NEW_LINE DEDENT