← Questions
Smallest valid task order from dependencies
0
I was asked this
No reports yet. Sign in to say where you were asked it.
There are n tasks numbered 0 to n - 1, done one at a time, and a list of pairs [a, b] meaning a must finish before b starts. Return an order that respects every dependency; among all valid orders, return the smallest one when compared position by position. If the dependencies contain a cycle, report that no order exists. (Kahn's algorithm with a min-heap instead of a plain queue.)
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
