cswork / libraryOpen practice workspace

Interview questions · Oracle

Return a valid course completion order

This question evaluates understanding of graph algorithms and dependency resolution, specifically skills in cycle detection and producing valid orderings of tasks.

You are given an integer n representing n courses labeled 0..n-1 and a list of prerequisite pairs prerequisites, where each pair [a, b] means you must complete course b before course a.

Return any valid ordering of courses you can take to finish all courses. If it is impossible due to cyclic prerequisites, return an empty list.

Requirements:

  • The solution should run efficiently for large n and prerequisite lists.

Community answers

Nothing here yet.

Join in on CSWork →