Reported September 2026
Googlegraph

Course Schedule II

Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Google OA. Under 2s to a working solution.
Founder's read

The Google OA reported in September 2026 gives you numCourses up to 2000 and up to 5000 prerequisite pairs. That rules out any approach that rescans every course for every round. It's Course Schedule II with a twist: instead of one flat order, you return nested rounds of courses that can be taken in parallel. The pattern is topological sort, level by level. If you've seen Kahn's algorithm, you're most of the way there. If you blank under the timer, StealthCoder is the safety net running invisibly during the live assessment.

The problem

There are numCourses courses labeled from 0 to numCourses - 1. Each pair [course, prerequisite] means the prerequisite must be completed before the course.
Return a nested list of parallel study rounds. Each round contains every course whose prerequisites were completed in earlier rounds, sorted in ascending order. If no valid schedule includes every course, return an empty outer array.

Function
findCourseOrder(numCourses: int, prerequisites: int[][]) → int[][]

Examples
Example 1
numCourses = 2
prerequisites = [[1,0]]
return = [[0],[1]]
Course 0 is available first. Completing it unlocks course 1 for the next round.
Example 2
numCourses = 4
prerequisites = [[1,0],[2,0],[3,1],[3,2]]
return = [[0],[1,2],[3]]
After course 0, courses 1 and 2 can be completed together; both unlock course 3.
Example 3
numCourses = 2
prerequisites = [[1,0],[0,1]]
return = []
The two courses form a cycle, so no schedule can include every course.

Constraints
1 <= numCourses <= 2000.
0 <= prerequisites.length <= 5000.
prerequisites[i].length == 2.
0 <= course, prerequisite < numCourses.
Every prerequisite pair is unique, and a course is never its own prerequisite.
Each course appears in exactly one returned round, and values inside a round are ascending.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is Kahn's algorithm processed in layers. Build an adjacency list and an indegree array. Seed the first round with every course at indegree 0. Then, for each round, sort it ascending, record it, and decrement the indegree of each neighbor. Any neighbor that hits 0 goes into the next round. That's O(V + E) plus sorting, which fits easily in the constraints. The common pitfall is cycle detection. Count how many courses you've placed. If the total is less than numCourses, return an empty outer array, not a partial schedule. Another slip is forgetting to sort each round, or mixing up the [course, prerequisite] direction when building edges. Edge goes from prerequisite to course. If you freeze on the layered BFS structure during the live OA, StealthCoder can hand you the working code so you can just verify it against the three examples.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Course Schedule II cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as course schedule ii. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Google's OA.

Google reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Course Schedule II FAQ

What's the trick to Course Schedule II with parallel rounds?+

Use Kahn's algorithm but process one full level at a time. Collect all courses with indegree 0 as a round, sort it, then release their neighbors. Courses that drop to indegree 0 form the next round. Repeat until the queue is empty.

How do I detect an impossible schedule?+

Count the courses you've placed across all rounds. If that count is less than numCourses, a cycle blocked some courses from ever reaching indegree 0. Return an empty outer array in that case, not the partial rounds you built.

Will DFS work instead of BFS here?+

DFS can detect cycles and give a topological order, but grouping into parallel rounds is awkward. You'd need to compute each node's depth. Level-by-level BFS with indegrees matches the output format directly, so it's the cleaner choice.

What's the time complexity for Google's constraints?+

Building the graph and processing every edge once is O(V + E), so about 7000 operations of core work. Sorting each round adds at most O(V log V) overall. With 2000 courses and 5000 pairs, this is far from a bottleneck.

How do I prepare for this in 48 hours?+

Write Kahn's algorithm from memory twice, then modify it to emit levels. Test the three examples, plus a case with no prerequisites and a cycle. Watch the edge direction, since pairs are [course, prerequisite]. That covers nearly every way this goes wrong.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Google.

OA at Google?
Invisible during screen share
Get it