Skip to content

Commit 4d552e3

Browse files
authored
Create Maximum Profit On App
1 parent bcda634 commit 4d552e3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
You have made a smartphone app and want to set its price such that the profit earned is maximised.
3+
There are certain buyers who will buy your app only if their budget is greater than or equal to your price.
4+
You will be provided with a list of size N having budgets of buyers and you need to return the maximum profit that you can earn.
5+
Lets say you decide that price of your app is Rs. x and there are N number of buyers. So maximum profit you can earn is : m * x
6+
where m is total number of buyers whose budget is greater than or equal to x.
7+
8+
Input format :
9+
Line 1 : N (No. of buyers)
10+
Line 2 : Budget of buyers (separated by space)
11+
12+
Output Format :
13+
Maximum profit
14+
15+
Constraints :
16+
1 <= N <= 10^6
17+
18+
Sample Input 1 :
19+
4
20+
30 20 53 14
21+
Sample Output 1 :
22+
60
23+
Sample Output 1 Explanation :
24+
Price of your app should be Rs. 20 or Rs. 30. For both prices, you can get the profit Rs. 60.
25+
26+
Sample Input 2 :
27+
5
28+
34 78 90 15 67
29+
Sample Output 2 :
30+
201
31+
Sample Output 2 Explanation :
32+
Price of your app should be Rs. 67. You can get the profit Rs. 201 (i.e. 3 * 67).
33+
*/
34+

0 commit comments

Comments
 (0)