✅ JAVA Solution
JAVA Solution\n\nJAVA []\nclass Solution {\n    class Pair implements Comparable<Pair> {\n        int capital, profit;\n\n        public Pair(int capital, int p
# JAVA Solution\n\n``` JAVA []\nclass Solution {\n    class Pair implements Comparable<Pair> {\n        int capital, profit;\n\n        public Pair(int capital, int profit) {\n            this.capital = capital;\n            this.profit = profit;\n        }\n\n        public int compareTo(Pair pair) {\n            return capital - pair.capital;\n        }\n    }\n    \n    public int findMaximizedCapital(int k, int w, int[] profits, int[] capital) {\n        int n = profits.length;\n        Pair [] projects = new Pair[n];\n        for(int i = 0;i<n;i++){\n            projects[i] = new Pair(capital[i],profits[i]);\n        }\n        \n        Arrays.sort(projects);\n        PriorityQueue<Integer> priority = new PriorityQueue<Integer>( Collections.reverseOrder());\n        int j = 0;\n        int ans = w;\n        for(int i = 0;i<k;i++){\n            while(j<n && projects[j].capital<=ans){\n                priority.add(projects[j++].profit);\n            }\n            if(priority.isEmpty()){\n                break;\n            }\n            ans+=priority.poll();\n        }\n        return ans;\n    }\n}\n```\n\n![kitty.jpeg](https://assets.leetcode.com/users/images/71163b5c-810d-407c-a05d-6a7d579807c9_1677123425.7876282.jpeg)\n
['Java']