← Citadel Interview Insights

Citadel·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Citadel software engineer interview that came down to a graph problem. The whole session was essentially one meaty algorithmic question with follow-ups on implementation choices and complexity.

Questions Asked (1)

Q1

Given a list of courses and their prerequisites, return a valid order to take all courses. If no valid ordering exists, return an empty array.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Classic topological sort.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the courses and prerequisites as a directed graph and perform a topological sort using Kahn's algorithm (BFS) or DFS. If the topological sort does not include all courses, a cycle exists, so return an empty array.

Pro tip: Mention that Kahn's algorithm naturally detects cycles by checking if the number of processed nodes equals the total number of courses, and discuss how this approach can be extended to handle real-world scenarios like detecting conflicting prerequisites or parallel course scheduling.

1. Clarify the problem

Confirm input format (e.g., number of courses, list of prerequisite pairs) and output expectations (any valid order or specific order). Ask about edge cases like no prerequisites or duplicate edges.

2. Choose the algorithm

Decide between Kahn's algorithm (BFS-based) and DFS-based topological sort. Explain that Kahn's is often preferred for its intuitive cycle detection and ability to process nodes in parallel.

3. Build the graph and compute in-degrees

Create an adjacency list for the graph and an array to track in-degrees of each node. Initialize a queue with all nodes having in-degree zero.

4. Perform topological sort

While the queue is not empty, dequeue a node, add it to the result, and for each neighbor, decrement its in-degree; if it becomes zero, enqueue it. After processing, check if the result length equals the number of courses.

5. Handle cycles and return result

If the result length is less than the number of courses, a cycle exists, so return an empty array. Otherwise, return the result as a valid ordering.

Key Points to Mention

  • Topological sorting is the core concept for ordering tasks with dependencies.
  • Kahn's algorithm uses BFS and in-degree tracking, while DFS uses recursion and post-order traversal.
  • Cycle detection is crucial: if a cycle exists, no valid ordering is possible.
  • Time complexity is O(V + E) and space complexity is O(V + E) for both approaches.
  • Edge cases: empty input, no prerequisites, duplicate edges, and disconnected graphs.
  • Real-world applications: course scheduling, build systems, task dependency resolution.

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