Maximize Startup Credits by Funding At Most K Projects
Last updated: November 29, 2026
Quick Overview
A Microsoft for Startups program starts with a credit budget. Each project needs a minimum budget on hand to start and adds a known net gain when done; fund at most k projects one after another and return the largest final budget.
Microsoft
November 29, 20260
0
0 solved
A Microsoft for Startups program starts with a credit budget. Each project needs a minimum budget on hand to start and adds a known net gain when done; fund at most k projects one after another and return the largest final budget.
A two-heap greedy problem in Microsoft onsite style. The interviewer wants the candidate to argue why picking the largest affordable gain each round is optimal and to implement it with a sorted list plus a max-heap.
What the Interviewer Expects
- Sort projects by required budget
- Each round, move newly affordable projects into a max-heap of gains
- Take the largest gain, since gains never reduce the budget
- Stop early when nothing is affordable
- Explain the exchange argument for optimality
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Projects can have negative returns. Does the greedy still work?
- Several projects can run in parallel if the budget covers all of their requirements.
- k is huge (up to n) and n is a million. Any concern with this approach?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
budget: starting credits;k: max projects.- Project i is available if
costs[i] <= budget; finishing it addsreturns[i] >= 0. - Each project at most once; return the final budget....
High-Level Design
Because gains are non-negative, the budget only grows, so any project affordable now stays affordable. Among those, taking the largest gain is never worse: suppose an optimal plan takes a smaller one ...