Study
7 Most-Reported Topological Sort Questions at Big Tech (2026)
TrueInterview
October 26, 2026 · 14 min read

As of 2026-10-26, TrueInterview's bank holds 53 candidate-reported cycle detection and dependency ordering questions from 17 big-tech companies. Seven titles carry the most write-ups, led by Course Schedule with 21 links from candidates at Amazon, Google, Snowflake, Uber, Netflix and Meta. Course Schedule is the floor, not the target: the applied titles below it, whose names point to ads scheduling, build order, service ordering and version checks, are written up mostly by senior-or-above candidates. In our reading, they move the work from answering true or false to modelling a domain and returning an order.
Disclosure: TrueInterview is an interview-preparation product and publishes this article. Facts about other products come from their public pages on the dates listed under Sources.
Which topological sort questions do candidates report most?
Course Schedule leads, followed by an ads-scheduling variant at Amazon and Netflix and ByteDance's DAG execution-order question. Every example round we have for the top seven is a phone screen, dated between 2026-03 and 2026-10. The ranking counts candidate write-ups that link to each question, which shows what candidates wrote up, not how often a company asks it.

| Rank | Question | Companies linking it | Example round, last reported | Write-up links | Senior-or-above links | Practise |
|---|---|---|---|---|---|---|
| 1 | Course Schedule | Amazon, Google, Snowflake, Uber, Netflix, Meta | Apple, phone screen, 2026-10 | 21 | 9 | Course Schedule |
| 2 | Topological Sort / Course Schedule for Ads | Amazon, Netflix | Netflix, phone screen, 2026-07 | 11 | 10 | Course Schedule for Ads |
| 3 | Print Execution Order in a DAG and Detect Cycles | ByteDance | ByteDance, phone screen, 2026-10 | 8 | 2 | DAG execution order |
| 4 | Dependency Resolution / Build Order | Amazon, Airbnb, OpenAI | Airbnb, phone screen, 2026-09 | 7 | 4 | Build order |
| 5 | Course Schedule Cycle Detection | Snapchat, ByteDance | Snapchat, phone screen, 2026-06 | 5 | 1 | Cycle detection |
| 6 | Dependency Version Check | OpenAI | OpenAI, phone screen, 2026-05 | 5 | 5 | Version check |
| 7 | Service Dependency Topological Order | Uber | Uber, phone screen, 2026-03 | 3 | 2 | Service order |
Linking and filing are different counts. Course Schedule is filed under 9 big-tech companies, adding Apple, DoorDash and Snapchat to the six that link it. The ads variant is also filed under ByteDance, and so is the build-order question. Levels in the senior column are what candidates reported on their own write-ups.
Read the table as two groups. Course Schedule is the shared core every candidate should finish fast, and ByteDance's DAG question is the variant whose title explicitly asks for an execution order and a cycle report. Rows 2, 4, 6 and 7 are the applied variants, and two of them are linked from a single company, OpenAI for the version check and Uber for service ordering, so do not treat those as big-tech-wide prompts. These are candidate-reported questions reconstructed for practice, not any company's official question list.
Why is this mainly a phone-screen pattern?
Because the round data says so: of the 53 questions, 33 were reported in phone screens, 18 in onsites and 6 in online assessments, and a question can appear in more than one round. We read this as a speed bar: a clean, bug-free implementation inside one short round matters more than depth of graph theory.
The tags do not separate the two rounds. Among the 33 phone-screen questions, 19 carry a graphs tag and 15 a topological-sort tag. Among the 18 onsite questions, the split is 13 and 9. The phone-screen lean comes from the round counts alone. The data is also current: 48 of the 53 questions were last reported within the 12 months before 2026-10-26.
Our take: the usual advice is to learn topological sort conceptually and move on. Our reading of the round data argues for a speed target. If your next round is a phone screen, rehearse Kahn's algorithm or three-colour DFS until you can write it cleanly, in-degree updates and visiting states included, and keep most of the round free for the follow-up.
What do the questions beyond LeetCode 207 ask?
They change what you return. The boolean question asks whether all courses can be finished; the reported variants ask for a valid order, a cycle report, or a dependency model built from a product description. A Google coding report from October 2026, rated hard, was titled Course Scheduling and Dependency Variants in TrueInterview's feed, which fits that move past true or false.
| Level | What you return | Reported titles | Practise |
|---|---|---|---|
| 0. Can you finish? | A boolean | Course Schedule, Course Schedule Cycle Detection (Snapchat, ByteDance) | Course Schedule |
| 1. Return the order | A valid order, or a cycle report | Return a valid course completion order (Oracle, onsite, 2026-03); Print Execution Order in a DAG and Detect Cycles | Valid completion order |
| 2. Model a domain | An order over packages, services, ads or versions | Package Dependency Installation & Build Order (Amazon, phone screen, 2026-08); build order; ads; service ordering; version check | Package build order |
| 3. Add weights | A finish time, plus a cycle check | Minimum Time to Finish All Dependent Tasks with Durations (Detect Cycles), filed under 2 companies with 1 write-up | Tasks with durations |
Level 0: the boolean core
Hello Interview's Course Schedule page frames the task as returning true "if a topological ordering exists (all courses can be completed), otherwise false if a cycle prevents completion." Wikipedia states that a topological ordering is possible only when the graph has no directed cycles, so the question reduces to cycle detection. Solve it once with Kahn's algorithm and once with DFS colouring, then stop spending time here.
Level 1: return the order or report the cycle
The Oracle title and ByteDance's DAG question both want the order itself. cp-algorithms describes the general task as having to "check whether these constraints are contradictory, and if not, output the variables in ascending order". In practice, that means your function returns a list and a cycle signal, and you tell the interviewer before coding which of the valid orders you will produce.
Level 2: build the graph from a product description
Here the algorithm stays the same and the modelling becomes the question. Wikipedia lists ordering compilation tasks in makefiles and resolving symbol dependencies in linkers among the uses of topological sorting, which is what the Amazon and Airbnb build-order titles resemble. We read the ads, service and version titles from their names only, so open each practice page for the exact rule. In our view, the decisions most likely to come up for each are the edge direction (does an edge point from a dependency to its dependent, or the reverse), what the system returns when dependencies contradict each other, and whether the output order must be deterministic.
Level 3: weights on the nodes
The durations title adds a finish time on top of the order. The standard approach processes tasks in topological order and sets each task's earliest finish to its own duration plus the latest finish among its prerequisites; the answer is the largest finish time. Keep the cycle check, because a cycle makes the finish time undefined.
Which companies report these questions, and how do they frame them?
Amazon has the most questions in this pattern with 13, followed by Google with 10 and ByteDance with 9; Uber and OpenAI have 5 each, Meta, Snapchat and Snowflake 4 each, and Apple and Netflix 3 each. The tag mix matters more than the count. Uber's questions lean on topological sort, Google's lean on general graphs, and Amazon's split evenly, so the label you expect does not tell you how the prompt will be framed.
| Company | Questions | Graphs tag | Topological-sort tag | Example reported title |
|---|---|---|---|---|
| Amazon | 13 | 7 | 7 | Package Dependency Installation & Build Order |
| 10 | 8 | 5 | Course Scheduling and Dependency Variants | |
| ByteDance | 9 | 6 | 5 | Print Execution Order in a DAG and Detect Cycles |
| Uber | 5 | 1 | 4 | Service Dependency Topological Order |
| OpenAI | 5 | 2 | 3 | Dependency Version Check |
| Meta | 4 | 3 | 2 | Course Schedule |
The graphs-tagged questions include reachability problems rather than prerequisite ordering. Uber's file holds Reachability with restricted backward moves and prime-step jumps (digit contains 3), linked from 2 write-ups. A directed-graph question on players with unique ranks from match results is filed under 2 companies and linked from 2 write-ups.
Outside our bank, FastPrep labels its version as "Course Schedule Cycle Detection (Google Onsite Interview)"; our own reports for that title come from Snapchat and ByteDance. Our take: a graphs tag does not tell you what a prompt asks, so whichever company is next, add general directed-graph traversal, reachability included, to your plan. Two reachability titles in the bank make a practice set: Unique Ranks from Match Results and Uber's Reachability with Prime-Step Jumps. Uber's file is otherwise mostly topological sort, 4 of its 5 questions, so for Uber spend most of the time on service ordering.
Kahn's algorithm or DFS colouring: which should you use?
Use Kahn's algorithm by default and switch to DFS when you must name the nodes in a cycle. Wikipedia notes that the usual algorithms run in time linear in nodes plus edges, and Hello Interview's page gives both its solutions O(V + E) time. Neither is faster; the difference that matters in a phone screen is how each one reports a cycle.
| Criterion | Kahn's algorithm (BFS with in-degrees) | DFS with three colours |
|---|---|---|
| Cycle check | Edges remain after processing | The search reaches a gray (visiting) node |
| Output order | Direct; the pending structure decides which valid order you get | Reverse of the finish order |
| Naming the cycle | Leftover nodes include those that only depend on the cycle | Walk the parent array back from the gray node |
| Recursion depth | None | Can hit the recursion limit on long chains |
| Best for | Returning an order with a simple cycle flag | Explaining exactly which nodes form the cycle |
For Kahn's, Hello Interview's page states the check plainly: "If we process all courses, the graph is acyclic; otherwise, a cycle exists." Wikipedia's pseudocode returns an error if edges remain after processing, and Wikipedia adds that the pending structure can be a set, a queue or a stack. For DFS, cp-algorithms colours every vertex white at the start, gray on entry and black on exit, and treats a move to a gray vertex as a found cycle. Wikipedia's version of the same idea stops with "if n has a temporary mark then stop (graph has at least one cycle)". cp-algorithms also notes that appending each vertex as its call finishes gives the reversed topological order.
Two reminders apply to both. Wikipedia notes that a topological order is not necessarily unique, so if the interviewer wants the smallest order lexicographically, replace Kahn's queue with a min-heap and say so. Use an adjacency list, which Hello Interview's page notes gives O(V + E) space instead of O(V²) for a matrix.
Our take: Kahn's wins for most candidates because the order falls out of the loop and the cycle flag is one comparison. Pick DFS only if the prompt asks you to print or explain the cycle, and then rehearse the parent-array walk until it is routine.
What mistakes do candidates make on these problems?
The common traps, as Hello Interview's page lists them, are about state handling, not about choosing BFS or DFS. Hello Interview's Course Schedule page lists treating prerequisites as undirected edges, skipping disconnected components, and wrong in-degree updates in the BFS approach.
Work through this checklist before you call your solution done:
- Visiting state. Hello Interview's page also warns that "forgetting to mark nodes as 'visiting' during recursion leads to incorrect cycle detection".
- Every component. Start a DFS from every unvisited node, or seed the queue with every zero in-degree node, because Hello Interview's page notes that some courses form separate subgraphs.
- Input quirks. Hello Interview's Course Schedule page says the graph may contain multiple edges and self-loops. Test a self-loop, a duplicated edge and a graph with two separate components.
- Assumed acyclicity. cp-algorithms gives a DFS topological sort that assumes the graph is acyclic, so a copied routine needs its own cycle check.
- The undirected shortcut. cp-algorithms explains that for undirected graphs a simple visited flag is enough, with no need to tell gray from black. On a directed graph, it reports false cycles.
What changes at senior and staff level?
The pattern is not a junior topic: write-ups link these questions 54 times from candidates who reported a senior, staff-plus or manager level and 45 times from junior, new-grad or intern candidates. What changes is the question. Plain Course Schedule and ByteDance's DAG question lean junior, while the applied variants in the ranked table lean senior.
Course Schedule has 12 of its 21 links from junior, new-grad or intern candidates, and the DAG question has 6 of its 8. On the other side, the senior column of the ranked table shows the ads, version-check and build-order titles. One of the two senior-or-above write-ups on Uber's service ordering comes from a staff-plus or manager candidate. Counts this small show direction, so use them to order your practice, not to predict your interviewer.
Our take: at senior level the algorithm is assumed. The signal comes from turning a product description into nodes and edges, choosing what to return when a cycle appears, and saying which valid order you produce and why. Say those three things before you write a line of code.
Our take: a dependency question adds to your level signal when you discuss partial failure, such as what a build system should do with the packages that do not sit on the cycle.
Worked example: a senior engineer with an Amazon phone screen
Take a senior engineer three weeks from an Amazon phone screen. Of Amazon's 13 questions in this pattern, 7 carry a graphs tag and 7 a topological-sort tag, and one question can carry both, so prepare both general traversal and ordering. Three Amazon-linked titles cover the ordering half, and the plan below runs them from the boolean warm-up to the applied version.
- Warm-up. Solve Course Schedule with Kahn's algorithm under a phone-screen timer. It is linked by Amazon candidates among others.
- Senior-skewed variant. Solve Topological Sort / Course Schedule for Ads, the second most-linked title, with Amazon and Netflix candidates linking it. Before coding, state what a node and an edge mean.
- Applied build order. Solve Package Dependency Installation & Build Order, the Amazon phone-screen example from 2026-08. Return a valid install order, and when none exists, name the packages on the cycle.
How we counted
Counts come from TrueInterview's question bank as of 2026-10-26 and cover questions tagged cycle detection or dependency ordering at big-tech companies. TrueInterview says each report is checked against other reports of the same round and dated with the month wherever the report gave one. Write-up links count candidate write-ups that point to a question, split by each candidate's self-reported level and role; they measure what candidates wrote up, not how often a company asks. A question can sit under several companies and rounds, so tallies overlap.
FAQ
Is Course Schedule II (LeetCode 210) reported?
Yes, in substance. The closest reported title is Oracle's Return a valid course completion order, from an onsite in 2026-03, and ByteDance's DAG question also asks for an execution order. Treat both as the reported form of Course Schedule II, since each wants the order rather than a boolean. Write your Course Schedule solution so it returns the processed list and flags a cycle when that list comes up short; the same function then answers both versions.
Do ML engineers get topological sort questions?
Yes. By the role on the write-up, 81 links come from software engineers and 11 from machine learning engineers. Dependency Version Check is linked 4 of 5 times by machine-learning, AI, research or data-science candidates, and Course Schedule Cycle Detection 3 of 5 times. Course Schedule itself has 4 such links out of 21. If you are an ML candidate targeting OpenAI, add the version check to your plan.
How do I return the cycle instead of true or false?
Run DFS with three colours and record each node's parent as you descend. When the search reaches a gray node, walk the parent array back from the current node until you reach that gray node again; the nodes you pass form the cycle. cp-algorithms notes the cycle "can be reconstructed using parent array." Return it in edge order so you can read it to the interviewer as a chain of dependencies.
What is the time and space complexity of the standard solutions?
Both run in O(V + E) time. Wikipedia explains that the DFS version is linear because each edge and node is visited once, and cp-algorithms gives cycle detection by DFS as linear in the number of edges. Space is O(V + E) with an adjacency list, plus the queue or recursion stack. State both bounds without being asked, and mention that a matrix would cost O(V²) space.
Your practice plan
The target is narrow: seven recurring titles share one linear-time core, and each new variant is mostly a modelling exercise on top of it. A three-week plan for someone working full time, about an hour on weekdays:
- Week one, the core. Implement Kahn's algorithm from scratch, returning both the order and a cycle flag, and solve Course Schedule with it under a phone-screen timer.
- Week one, edge cases. Rerun your solution on a self-loop, a duplicated edge and a disconnected graph, then solve Course Schedule Cycle Detection with DFS colouring.
- Week two, return the order. Solve Return a valid course completion order and Print Execution Order in a DAG and Detect Cycles. Add parent-array cycle reconstruction to the DFS version.
- Week two, applied models. Solve Dependency Resolution / Build Order and Topological Sort / Course Schedule for Ads. State the nodes, the edge direction and the cycle behaviour before coding.
- Week three, your companies. Pick the titles on file for your targets: Service Dependency Topological Order for Uber, Dependency Version Check for OpenAI, Package Dependency Installation & Build Order for Amazon.
- Week three, weights and rehearsal. Solve Minimum Time to Finish All Dependent Tasks with Durations, then redo one applied title as a timed phone screen, saying which valid order you return.
Sources
- TrueInterview question bank — cycle detection and dependency ordering at big-tech companies — counted 2026-10-26
- Real FAANG Interview Questions by Company · TrueInterview — checked 2026-10-26
- Leetcode 207. Course Schedule | Hello Interview — checked 2026-10-26
- Topological sorting - Wikipedia — checked 2026-10-26
- Topological Sorting - Algorithms for Competitive Programming — checked 2026-10-26
- Course Schedule Cycle Detection (Google Onsite Interview) - Coding Interview Problem | FastPrep — checked 2026-10-26
- Checking a graph for acyclicity and finding a cycle in O(M) - Algorithms for Competitive Programming — checked 2026-10-26
- Interview prep compared: your application, end to end · TrueInterview — checked 2026-10-26
Last reviewed: 2026-10-26.