[Python] Two heaps greedy solution with simple explanation
\nfrom heapq import *\n\nclass Solution:\n    def findMaximizedCapital(self, k: int, w: int, profits: List[int], capital: List[int]) -> int:\n        minCapital
```\nfrom heapq import *\n\nclass Solution:\n    def findMaximizedCapital(self, k: int, w: int, profits: List[int], capital: List[int]) -> int:\n        minCapitalHeap = []\n        maxProfitHeap = []\n\n        # Insert all capitals to a min-heap\n        for i in range(0, len(profits)):\n            heappush(minCapitalHeap, (capital[i], i))\n\n        # Finding \'k\' best projects\n        availableCapital = w\n        for _ in range(k):\n            # Projects that can be selected within the available capital. Insert these in a max-heap\n            while minCapitalHeap and minCapitalHeap[0][0] <= availableCapital:\n                capital, i = heappop(minCapitalHeap)\n                heappush(maxProfitHeap, (-profits[i], i))\n\n            # Break if we are not able to find any project that can be completed within the available capital\n            if not maxProfitHeap:\n                break\n\n            # Add the profit from project with the maximum profit\n            availableCapital += -heappop(maxProfitHeap)[0]\n\n        return availableCapital\n```\n\n**Time Complexity:**\nWe can see that all the projects are getting pushed to both the heaps once. Thus, the time complexity of our algorithm is O(NlogN + KlogN), where \u2018N\u2019 is the total number of projects and \u2018K\u2019 is the number of projects we are selecting.\n\n**Space Complexity:**\nO(N) because we are storing all the projects in the heaps.\n\nIf you like my approach then please give an upvote. Also, if you have any doubt feel free to ask. Thank you.
['Greedy', 'Heap (Priority Queue)', 'Python', 'Python3']