Deviopath › Go

Course Order

Hard · Algorithms

n courses 0…n-1 and prerequisites [a, b] meaning b before a. Return a valid order, or an empty slice if there is a cycle. If several orders are valid, return the one that always pops the smallest ready node (Kahn with a min-heap / sorted queue).

Write Order(n, prereq).

Next: Merge Intervals