MCPcopy Index your code
hub / github.com/neetcode-gh/leetcode / findOrder

Function findOrder

javascript/0210-course-schedule-ii.js:8–15  ·  view source on GitHub ↗
(numCourses, prerequisites)

Source from the content-addressed store, hash-verified

6 * @return {number[]}
7 */
8var findOrder = function (numCourses, prerequisites) {
9 const { graph, color, isDirectedAcyclicGraph, topologicalOrder } =
10 buildGraph(numCourses, prerequisites);
11
12 search(numCourses, graph, color, topologicalOrder, isDirectedAcyclicGraph);
13
14 return isDirectedAcyclicGraph[0] ? topologicalOrder.reverse() : [];
15};
16
17var initGraph = (numCourses) => ({
18 graph: new Array(numCourses).fill().map(() => []),

Callers

nothing calls this directly

Calls 4

buildGraphFunction · 0.70
searchFunction · 0.70
topologicalSortFunction · 0.70
reverseMethod · 0.45

Tested by

no test coverage detected