[Python] greey with min heap queue, Explained
Step 1, sort the profits based on the captial we need to gain the profit\nStep 2, based on the capital we have, add the profit into a min heap (add the negative
Step 1, sort the profits based on the captial we need to gain the profit\nStep 2, based on the capital we have, add the profit into a min heap (add the negative profit)\nStep 3, every loop, we pick the head from the heap, which is the largest profit we can gain\nStep 4, check the project list and add more projects based on the current profit\n\nAfter k loops, we can return the maximum capital we have.\n\n```\nclass Solution:\n    def findMaximizedCapital(self, k: int, w: int, profits: List[int], capital: List[int]) -> int:\n        # sort the profits based on the capital required\n        cap_profits = list(zip(capital, profits))\n        cap_profits.sort()\n        \n        profit_list, proj_cnt, prev_proj_cnt = [], 0, -1\n        \n        idx = 0\n        while proj_cnt < k and proj_cnt != prev_proj_cnt:\n            prev_proj_cnt = proj_cnt\n            while idx < len(profits) and cap_profits[idx][0] <= w:\n                heapq.heappush(profit_list, -(cap_profits[idx][1]))\n                idx += 1\n\n            # pick the largest profit we can get from the profit list\n            if profit_list:\n                w -= heapq.heappop(profit_list)\n                proj_cnt += 1\n            \n        return w\n```
['Heap (Priority Queue)', 'Python3']