Maximum Microsoft Learn Modules Finished Before Their Deadlines
Last updated: November 29, 2026
Quick Overview
Each Microsoft Learn module has a duration and a deadline, you study one module at a time starting at time 0, and a module counts only if it finishes by its deadline. Return the maximum number of modules you can complete.
Microsoft
November 29, 20260
0
0 solved
Each Microsoft Learn module has a duration and a deadline, you study one module at a time starting at time 0, and a module counts only if it finishes by its deadline. Return the maximum number of modules you can complete.
Asked in later Microsoft onsite rounds to separate candidates who know an exchange argument from those who reach for exponential DP. The interviewer is checking for the deadline sort plus max-heap swap and a convincing correctness argument.
What the Interviewer Expects
- Sort by deadline and explain why that ordering is canonical
- Use a max-heap of durations and swap out the longest when over the deadline
- Argue the exchange step keeps the count and never increases elapsed time
- Reach O(n log n) time
- Handle modules longer than their own deadline
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
- How would you maximize total points if each module had a different value?
- Can you return which modules were chosen?
- What if modules can be paused and resumed?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input: list of
[duration, deadline]pairs. - Modules run back to back without overlap, starting at time 0.
- A module counts if its finish time is at most its deadline.
- Output: the maximum count...
High-Level Design
If a set of modules is feasible in any order, it is feasible in deadline order, by a standard swap argument. So we process modules sorted by deadline and maintain the best set seen so far.
For each m...