Simple || Concise || Beginner Friendly || Greedy ✅✅
Complexity\n- Time complexity: O(n*log n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n
# Complexity\n- Time complexity: $$O(n*log n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n```\nclass Solution {\n    public int findMaximizedCapital(int k, int w, int[] profits, int[] capital) {\n        int n=capital.length, pc[][]=new int[n][2];\n        for(int i=0;i<n;i++){\n            pc[i][0]=profits[i];\n            pc[i][1]=capital[i];\n        }\n        Arrays.sort(pc, (a,b)->a[1]-b[1]);\n        PriorityQueue<int[]> pq = new PriorityQueue<>((a,b)->b[0]-a[0]);\n        int maxCap=w, i=0;\n        while(k-->0) {\n            for(; i<n && maxCap>=pc[i][1]; i++) \n                pq.add(pc[i]);\n            if(pq.isEmpty()) break;\n            maxCap+=pq.poll()[0];\n        }\n        return maxCap;\n    }\n}\n```
['Greedy', 'Sorting', 'Heap (Priority Queue)', 'Java']