Order tasks with mandatory and costed optional dependencies, breaking cycles cheaply.
Unlock detailed company stats for this questionUpgrade
Given tasks numbered 0 to n-1 and two types of dependencies: mandatory dependencies (strictly required sequence) and optional dependencies, each with an associated cost.
Determine a valid execution order. If a valid sequence exists using all dependencies, return it. If a cycle is detected, remove the optional dependency with the minimum cost that breaks the cycle and return the resulting order. If the cycle consists purely of mandatory dependencies, it cannot be resolved, so return an empty list.
Community answers
No answers contributed by the community yet.


