Minimum Wall Clock Time to Build a Visual Studio Solution
Last updated: November 29, 2026
Quick Overview
Each project in a Visual Studio solution has a compile time and a list of projects it depends on. With unlimited parallel build agents, a project can start once all its dependencies finish. Return the minimum total time to build everything, or -1 if the dependencies contain a cycle.
Microsoft
November 29, 20260
0
0 solved
Each project in a Visual Studio solution has a compile time and a list of projects it depends on. With unlimited parallel build agents, a project can start once all its dependencies finish. Return the minimum total time to build everything, or -1 if the dependencies contain a cycle.
A topological sort question in the style of Microsoft onsites, framed around MSBuild parallel builds. The interviewer checks that you see the answer as the critical path (longest weighted path in a DAG), compute it during Kahn's algorithm, and detect cycles.
What the Interviewer Expects
- Model projects as a DAG with edges from dependency to dependent
- Recognize the answer is the longest weighted path
- Compute earliest finish times in topological order
- Detect cycles when not all nodes are processed
- Explain why unlimited agents make this a pure DAG problem
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 does the problem change with only P build agents?
- How would you report the critical path itself?
- How would you make incremental builds recompute only affected projects?
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: times[i] for projects 0..n-1 and deps, a list of pairs (a, b) meaning a must finish before b starts. Output: earliest time when every project is done, or -1 on a cycle. Unlimited parallel...
High-Level Design
Run Kahn's algorithm. finish[v] starts as times[v] for projects with no dependencies. When we pop a project u from the ready queue, for each dependent v we update `start[v] = max(start[v], fin...