IPO
Return the maximum capital after completing at most k projects.
Examples
Input: [2,0,[1,2,3],[0,1,1]]
Output: 4
Input: [3,0,[1,2,3],[0,1,2]]
Output: 6
Hints
Use a min-heap to sort projects by their capital requirements, then iterate through them while maintaining a max-heap of projects that can be afforded with the current capital.
After each project completion, update the current capital and re-evaluate the affordable projects by moving newly affordable projects from the min-heap to the max-heap.
Optimize by tracking the smallest capital requirement in the min-heap and the largest profit in the max-heap to efficiently manage project selection and termination conditions.
IPO
Return the maximum capital after completing at most k projects.