← modular Interview Insights

modular·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Interviewed for a software engineering role at Modular and got hit with a graph problem about finding the critical path in a directed acyclic graph. Pretty algorithmic, no behavioral stuff from what I can tell. The problem had a bunch of test cases which was either reassuring or a sign they wanted to see you handle edge cases carefully.

Questions Asked (1)

Q1

Given a directed acyclic graph of tasks where each task has a name, a list of prerequisite tasks, and a duration, write a function that returns the critical path value (the maximum total duration along any dependency chain) and one corresponding ordered list of task names on that longest path.

Algorithms & Data StructuresSystem Design
Author's notes

This is basically topological sort plus dynamic programming once you see it clearly, but I spent a few minutes fumbling around trying to think about it as a pure DFS before remembering you can just compute earliest completion times in topo order.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a longest path in a DAG, using topological sort and dynamic programming to compute the maximum duration to each task. Track predecessors to reconstruct one critical path, and return both the total duration and the ordered task list.

Pro tip: Clarify upfront whether the graph is guaranteed acyclic and whether multiple critical paths exist—then state that you'll return any one of them. This shows you think about edge cases and ambiguity before coding.

1. Clarify inputs and constraints

Confirm the graph is a DAG, tasks are uniquely named, and durations are non-negative. Ask whether to return any critical path if multiple exist.

2. Build graph and compute in-degrees

Create an adjacency list from prerequisites to dependents and compute in-degrees for all tasks. This sets up topological sorting.

3. Topological sort and DP for longest path

Process tasks in topological order, updating the maximum duration to each dependent as current duration plus edge weight. Store the predecessor that gave the maximum.

4. Identify end of critical path and reconstruct

Find the task with the maximum total duration, then backtrack using stored predecessors to build the ordered list of task names.

5. Return result and discuss complexity

Return the maximum duration and the reconstructed path. Mention time and space complexity: O(V + E) time and O(V + E) space.

Key Points to Mention

  • Topological sorting (Kahn's algorithm or DFS) to process nodes in dependency order.
  • Dynamic programming recurrence: dist[v] = max(dist[v], dist[u] + duration[v]) for each edge u->v.
  • Predecessor tracking to reconstruct one critical path.
  • Handling multiple critical paths by returning any one.
  • Time and space complexity: O(V + E) for both.
  • Edge cases: empty graph, single task, disconnected components, and zero-duration tasks.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.