✅ beats 99% Java code
Java Code\n\nclass Solution {\n    public int findMaximizedCapital(int k, int W, int[] Profits, int[] Capital) {\n        int maxCapital = 0;\n        for (int 
# Java Code\n```\nclass Solution {\n    public int findMaximizedCapital(int k, int W, int[] Profits, int[] Capital) {\n        int maxCapital = 0;\n        for (int i = 0; i < Capital.length; i++) {\n            maxCapital = Math.max(Capital[i], maxCapital);\n        }\n\n        if (W >= maxCapital) {\n            PriorityQueue<Integer> maxHeap = new PriorityQueue<Integer>(new Comparator<Integer>() {\n                @Override\n                public int compare(Integer a, Integer b) {\n                    return a - b;\n                }\n            });\n            for (int p : Profits) {\n                maxHeap.add(p);\n                if (maxHeap.size() > k) maxHeap.poll();\n            }\n            for (int h : maxHeap) W += h;\n            return W;\n        }\n\n        int index;\n        int n = Profits.length;\n        for (int i = 0; i < Math.min(k, n); i++) {\n            index = -1;\n            for (int j = 0; j < n; ++j) {\n                if (W >= Capital[j] && (index == -1 || Profits[index] < Profits[j])) {\n                    index = j;\n                }\n            }\n            if (index == -1) break;\n            W += Profits[index];\n            Capital[index] = Integer.MAX_VALUE;\n        }\n        return W;\n    }\n}\n```
['Array', 'Greedy', 'Sorting', 'Heap (Priority Queue)', 'Java']