suppose LeetCode start ipo soon in order sell good price share Venture Capital LeetCode like work project increase capital IPO since limited resource finish k distinct project IPO help LeetCode design good way maximize total capital finish k distinct projectsyou give n project ith project pure profit profitsi minimum capital capitali need start itinitially w capital when finish project obtain pure profit profit add total capitalpick list k distinct project give project maximize final capital return final maximized capitalthe answer guarantee fit 32bit sign integer Example 1Input k 2 w 0 profit 123 capital 011output 4explanation since initial capital 0 start project index 0after finishing obtain profit 1 capital 1with capital 1 start project index 1 project index 2since choose 2 project need finish project index 2 maximum capitaltherefore output final maximized capital 0 1 3 4example 2input k 3 w 0 profit 123 capital 012output 6 Constraints1 k 1050 w 109n profitslengthn capitallength1 n 1050 profitsi 1040 capitali 109