IPO
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You start with capital w and may finish at most k distinct projects. Project i requires you to currently have at least capital[i] to start it, and completing it adds its pure profit profits[i] to your capital (the requirement is not spent).
Projects are done one after another, so profits earned early can unlock more expensive projects later. Return the maximum capital you can end with.
Aim for O((n + k) log n) time.
Examples
Constraints
- 1 <= k <= 10^5
- 0 <= w <= 10^9
- n == profits.length == capital.length
- 1 <= n <= 10^5
- 0 <= profits[i] <= 10^4
- 0 <= capital[i] <= 10^9
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.