We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e0a3495 commit 6e5e5baCopy full SHA for 6e5e5ba
Course 2 - Data Structures in JAVA/Test 1/Maximum Profit On App
@@ -32,3 +32,27 @@ 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
35
+import java.util.*;
36
+import java.lang.*;
37
+public class solution {
38
+
39
+ public static int maximumProfit(int budget[]) {
40
41
+ Arrays.sort(budget);
42
+ /*for (int i=0;i<budget.length;i++)
43
+ {
44
+ System.out.print(budget[i]+" ");
45
+ }*/
46
+ //System.out.println();
47
48
+ int ans=Integer.MIN_VALUE;
49
+ int n=budget.length;
50
+ // sort(budget,budget+n);
51
+ for(int i=0;i<n;i++)
52
53
+ ans=Math.max(ans,budget[i]*(n-i));
54
+ }
55
+ return ans;
56
57
58
+}
0 commit comments