IPO
You are given n projects.
For each project:
- profits[i] represents the profit you earn after completing project i.
- capital[i] represents the minimum capital required to start project i.
You initially have w units of capital.
You can complete at most k projects.
After completing a project, its profit is added to your available capital.
You may choose the projects in any order, but you can only start a project if your current capital is at least its required capital.
Return the maximum capital you can have after completing at most k projects.
Example 1
Input
n = 2 k = 1 w = 0 profits = [1, 2] capital = [0, 1]
Output
1
Explanation
Initially, you have 0 capital.
Only project 0 can be started because it requires 0 capital.
After completing it:
capital = 0 + 1 = 1
Since only one project can be completed, the answer is 1.
Example 2
Input
n = 3 k = 2 w = 0 profits = [1, 2, 3] capital = [0, 1, 1]
Output
4
Explanation
Initially:
capital = 0
Choose project 0:
capital = 0 + 1 = 1
Now projects 1 and 2 are available.
Choose project 2 with profit 3:
capital = 1 + 3 = 4
At most two projects are completed, so the answer is 4.
Constraints
Hints:
Hint 1
At any point, consider only projects whose required capital is less than or equal to your current capital.
Hint 2
Among all currently available projects, always choose the one with the maximum profit.
Author & Technical Reviewer
Technically reviewed by: ExamAdda Technical Review Team
Technical Reviewers, ExamAdda
Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.
Published
Aug 22, 2026
Last updated
Aug 22, 2026
Content Verification Methodology
Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.
Expected Output