Rules that allow only one order
A release has n steps numbered 0 to n - 1. Each pair [first, then] in rules means step first must happen before step then. If exactly one order of all n steps respects every rule, return that order as a list. Otherwise return []: either no order works (the rules contradict each other) or several do.
n ≥ 1; pairs may repeat, rules may be empty, and a rule like [2, 2] (a step before itself) can never be met.
Besides the tests, one large input (2,500 steps, 5,000 rules) with a ~100 ms limit (scaled to your device's speed): brute force won't pass.
Examples
only_order(3, [[0,1],[1,2]])→[0,1,2]only_order(3, [[0,1],[0,2]])→[]only_order(4, [[2,0],[0,3],[3,1],[2,3]])→[2,0,3,1]