From a30d802f0dbd0fab4594af5e4e910fc0b14fa5d2 Mon Sep 17 00:00:00 2001 From: Tanmay-312 Date: Sat, 15 Jun 2024 13:43:31 +0530 Subject: [PATCH] Added codes for 15 June --- GeeksForGeeks/June/15-6-24/GFG.java | 51 ++++++++++++++++++++++++++++ GeeksForGeeks/June/15-6-24/README.md | 2 ++ LeetCode/June/15-6-24/README.md | 2 ++ LeetCode/June/15-6-24/Solution.java | 35 +++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 GeeksForGeeks/June/15-6-24/GFG.java create mode 100644 GeeksForGeeks/June/15-6-24/README.md create mode 100644 LeetCode/June/15-6-24/README.md create mode 100644 LeetCode/June/15-6-24/Solution.java diff --git a/GeeksForGeeks/June/15-6-24/GFG.java b/GeeksForGeeks/June/15-6-24/GFG.java new file mode 100644 index 0000000..31f77ff --- /dev/null +++ b/GeeksForGeeks/June/15-6-24/GFG.java @@ -0,0 +1,51 @@ +//{ Driver Code Starts +// Initial Template for Java + +import java.io.*; +import java.util.*; + +class GfG { + public static void main(String args[]) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- > 0) { + int n = sc.nextInt(); + Solution ob = new Solution(); + System.out.println(ob.getCount(n)); + } + } +} +// } Driver Code Ends + + +// User function Template for Java + +class Solution { + public long getCount(int n) { + // Your code goes here + long[][] dp = new long[n][10]; + for(int i=0;i<10;i++) + { + dp[0][i] = 1; + } + for(int i=1;i minHeap = new PriorityQueue<>((a, b) -> a.cap - b.cap); + Queue maxHeap = new PriorityQueue<>((a, b) -> b.pro - a.pro); + + for (int i = 0; i < Capital.length; ++i) + minHeap.offer(new T(Profits[i], Capital[i])); + + while (k-- > 0) + { + while (!minHeap.isEmpty() && minHeap.peek().cap <= W) + maxHeap.offer(minHeap.poll()); + + if (maxHeap.isEmpty()) + break; + + W += maxHeap.poll().pro; + } + + return W; + } +}