MEDIUMasked at 33 companies

Course Schedule II

A medium-tier problem at 53% community acceptance, tagged with Depth-First Search, Breadth-First Search, Graph. Reported in interviews at Zenefits and 32 others.

Founder's read

Course Schedule II is a medium-difficulty graph problem that shows up in assessments from Zenefits, Intuit, Snowflake, Snap, Workday, and Salesforce. About half of candidates who attempt it solve it cleanly. The problem asks you to return the order in which courses can be taken given prerequisites, or detect if a valid order exists at all. This is a topological sort problem disguised as a scheduling question. If you haven't drilled topological sorting recently, this is the kind of problem where you blank on whether to use DFS or BFS, waste time second-guessing the approach, and run out of time. StealthCoder solves it invisibly during your live assessment if you hit that wall.

Companies asking
33
Difficulty
MEDIUM
Acceptance
53%

Companies that ask "Course Schedule II"

If this hits your live OA

Course Schedule II is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.

Get StealthCoder
What this means

The trick is recognizing this as a DAG (directed acyclic graph) topological sort. Build an adjacency list from prerequisites, then run either Kahn's algorithm (BFS with in-degree tracking) or DFS with a recursion stack. The common failure mode is trying to greedily pick courses without checking for cycles, or implementing DFS incorrectly and getting stuck in a loop. Most candidates know the pattern exists but fumble the graph construction or the base case for detecting impossible orderings. DFS is slightly more intuitive if you think of it as 'visit a course, recursively visit all its prerequisites first, then record the course.' BFS requires careful in-degree counting. Either way, the implementation is short but the logic is dense. If you haven't coded this exact pattern recently, you'll lose 10-15 minutes reconstructing it under pressure. StealthCoder gives you the correct implementation in seconds so you can move on.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Course Schedule II recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Course Schedule II interview FAQ

Is this really just topological sort?+

Yes. Prerequisites define edges in a directed graph. A valid course order is a topological ordering of that graph. If a cycle exists (circular prerequisites), no valid ordering exists. The problem is testing whether you know Kahn's or DFS-based topological sort. The course scheduling context is just flavoring.

DFS or BFS for this one?+

Both work. DFS is cleaner conceptually: mark the node as visiting, recurse on dependencies, mark as visited, add to result. BFS (Kahn's) is slightly safer if you struggle with recursion; track in-degrees, add all zero-in-degree nodes to a queue, process and decrement. Pick whichever you can implement without bugs under time pressure.

What's the acceptance rate really telling me?+

At 53%, roughly half of people nail it and half don't. That's not because the problem is conceptually hard. It's because the implementation requires precision: one off-by-one error, one missed edge case, or one logic flip in the cycle detection and you're wrong. Speed matters here. Knowing the pattern matters more.

Is this still asked at Salesforce and Snap?+

Yes. It appears in reports from 10 major companies including Salesforce, Snap, Workday, Snowflake, and Intuit. Topological sort is evergreen in systems and backend roles. The problem itself is a classic coding round question, not a screener.

What's the trap if I try to code it live without drilling it first?+

You'll get the adjacency list right, then blank on whether to detect cycles during construction or after. Or you'll implement DFS but forget to track the visiting state and infinite loop. Or you'll implement Kahn's but forget to check if all nodes were processed. These aren't conceptual gaps. They're implementation details that only muscle memory solves.

Want the actual problem statement? View "Course Schedule II" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.