Maximum Profit on App

You have made a smartphone app and want to set its price such that the profit earned is maximised. There are certain buyers who will buy your app only if their budget is greater than or equal to your price.

You will be provided with a list having budgets of buyers and you need to return the maximum profit that you can earn.

Input format :

Line 1 : N (No. of buyers)

Line 2 : Budget of buyers (separated by space)

Sample Input 1 :
4
30 20 53 14
Sample Output 1 :
60
Sample Input 2 :
5
34 78 90 15 67
Sample Output 2 :
201

Login to submit your solution

Fb dab53a1a64929320dc7425896aa73fd9e5512b6ab52e414ff5f3ebb5cecc73eb

Share Problem