← modular Interview Insights

modular·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026Remote

Summary

Interviewed for a software engineering role at Modular and got a graph algorithm problem. Pretty focused technical screen, nothing behavioral, just code and explain your reasoning.

Questions Asked (1)

Q1

Given a list of tasks with names, dependencies, and durations representing a directed acyclic graph, compute the critical path length (longest path by total duration) and return the actual sequence of tasks that forms that path. Handle multiple test graphs.

Algorithms & Data Structures
Author's notes

This is a classic DAG longest-path problem but the twist is you also have to reconstruct the path, not just return the length.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the tasks as a DAG and use topological sorting to compute the longest path to each node, tracking predecessors to reconstruct the critical path. For multiple test graphs, process each independently, ensuring efficient O(V+E) time per graph.

Pro tip: Clarify edge cases upfront (e.g., empty graph, disconnected components, multiple critical paths) and discuss how to handle them—this shows thoroughness and prevents ambiguity during implementation.

1. Understand the problem and clarify requirements

Confirm that the graph is a DAG, tasks have durations, and dependencies are directed edges. Ask about output format for multiple graphs and tie-breaking rules for multiple critical paths.

2. Design the algorithm

Use topological sort to process nodes in dependency order. For each node, compute the longest path ending at that node by taking the maximum over its predecessors, and store the predecessor that gives the maximum.

3. Implement and handle multiple graphs

Write a function that takes a graph and returns the critical path length and sequence. Loop over all test graphs, applying the function to each, and collect results.

4. Reconstruct the critical path

After computing longest distances, find the node with the maximum distance (end of critical path). Backtrack using stored predecessors to build the sequence of tasks from start to end.

5. Test and validate

Test with simple graphs (single node, chain, diamond) and edge cases (empty graph, multiple sources/sinks). Verify that the path length equals the sum of durations along the path.

Key Points to Mention

  • Topological sorting to ensure dependencies are processed before dependents.
  • Dynamic programming for longest path in a DAG: dist[v] = max(dist[u] + duration[v]) for all edges u->v.
  • Predecessor tracking to reconstruct the actual task sequence.
  • Time and space complexity: O(V+E) per graph, O(V) extra space.
  • Handling multiple test graphs by iterating and resetting state.
  • Edge cases: empty graph, disconnected components, multiple critical paths (tie-breaking).

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