Starting steps that reach everything
A workflow has n steps numbered 0 to n - 1. Each pair [a, b] in triggers means that when step a runs, it sets off step b. The triggers never form a cycle. You launch some steps by hand, and every step they set off, directly or down a chain, runs too. Return, in increasing order, the smallest set of steps to launch so that every step runs.
Pairs may repeat, and triggers may be empty.
Besides the tests, one large input (3,000 steps, 6,000 triggers) with a ~100 ms limit (scaled to your device's speed): brute force won't pass.
Examples
starting_steps(6, [[0,1],[0,2],[2,5],[3,4],[4,2]])→[0,3]starting_steps(5, [[0,1],[2,1],[3,1],[1,4],[2,4]])→[0,2,3]starting_steps(3, [])→[0,1,2]